catch all recording errors; mention permission

https://forums.ankiweb.net/t/i-have-an-error-when-i-try-to-record-of-audio/10483
This commit is contained in:
Damien Elmes 2021-06-02 12:14:20 +10:00
parent 578b1b0552
commit be9bbf2157
3 changed files with 12 additions and 5 deletions

View File

@ -29,7 +29,11 @@ qt-misc-manage-note-types = Manage Note Types
qt-misc-name-exists = Name exists.
qt-misc-non-unicode-text = <non-unicode text>
qt-misc-optimizing = Optimizing...
qt-misc-please-connect-a-microphone-and-ensure = Please connect a microphone, and ensure other programs are not using the audio device.
qt-misc-unable-to-record =
Unable to record. Please ensure a microphone is connected, and Anki has permission to use the microphone.
If other programs are using your microphone, closing them may help.
Original error: { $error }
qt-misc-please-ensure-a-profile-is-open = Please ensure a profile is open and Anki is not busy, then try again.
qt-misc-please-select-1-card = (please select 1 card)
qt-misc-please-select-a-deck = Please select a deck.

View File

@ -78,9 +78,6 @@ class ErrorHandler(QObject):
if "10013" in error:
showWarning(tr.qt_misc_your_firewall_or_antivirus_program_is())
return
if "no default input" in error.lower():
showWarning(tr.qt_misc_please_connect_a_microphone_and_ensure())
return
if "invalidTempFolder" in error:
showWarning(self.tempFolderMsg())
return

View File

@ -17,6 +17,8 @@ from concurrent.futures import Future
from operator import itemgetter
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, cast
from markdown import markdown
import aqt
from anki import hooks
from anki.cards import Card
@ -799,7 +801,11 @@ def record_audio(
else:
encode_mp3(mw, path, on_done)
_diag = RecordDialog(parent, mw, after_record)
try:
_diag = RecordDialog(parent, mw, after_record)
except Exception as e:
err_str = str(e)
showWarning(markdown(tr.qt_misc_unable_to_record(error=err_str)))
# Legacy audio interface