Damien Elmes
643e875342
add back pyaudio as an optional alternative
2020-12-18 16:52:00 +10:00
Damien Elmes
cd31780668
explicitly set sample rate and channels
...
Windows sounds awful by default on a machine here.
2020-12-16 20:18:13 +10:00
Damien Elmes
3a250f5238
formatting & mypy fix
2020-12-16 19:51:46 +10:00
Damien Elmes
1114ca75df
update recording time more frequently; remove print statement
2020-12-16 19:45:08 +10:00
Damien Elmes
ecb7c1482f
use QtMultimedia for recording instead of PyAudio
...
The unmute-on-first-duration-change approach is to try to prevent
clicks/pops that can happen at the start of recordings. If it doesn't
solve the problem, we may need to drop down to the lower-level
QAudioInput().
Closes https://github.com/ankitects/help-wanted/issues/23
May fix https://forums.ankiweb.net/t/anki-crashes-periodically-after-clicking-record-audio-button/5824 ,
which I suspect was caused by processEvents()
2020-12-16 19:33:25 +10:00
Damien Elmes
ffa26fe4bc
fix remaining _() references; remove unused imports
2020-11-18 12:43:46 +10:00
Damien Elmes
2453e5c488
update temporary val="%s" references to standard ftl
2020-11-17 22:00:44 +10:00
Damien Elmes
6418993840
merge bulk of qt/ - designer files still to do
2020-11-17 17:42:43 +10:00
ianki
c2901e4859
Add hooks for filtering media.
2020-11-09 02:12:23 -08:00
Damien Elmes
37695da713
fix missing QAudioDeviceInfo on macOS
2020-11-06 12:01:37 +10:00
Piotr Kubowicz
ed11f8e9d6
Add .opus as an audio extension
...
Wikimedia Commons has pronunciation recordings with .opus extension.
Anki is able to play such files, but until now adding them required
changing the extension to .ogg or some other supported one.
Also sort the audio extensions list.
2020-10-10 16:28:40 +02:00
kelciour
e2d98ebc26
Separate player for videos on Windows
...
https://forums.ankiweb.net/t/anki-crashes-because-of-mpv/3359/13
2020-10-03 22:53:17 +03:00
kelciour
72ea605050
Revert back to listening for idle callback
...
https://forums.ankiweb.net/t/anki-2-1-33-linux-audio-stops-working/3023
2020-09-16 09:25:18 +03:00
Damien Elmes
b47654fed7
fix formatting
2020-08-21 11:45:14 +10:00
Damien Elmes
095df2f6f8
Add comment
2020-08-21 11:10:30 +10:00
kelciour
8cac607588
Reset av_player.current_player after mpv restart
2020-08-21 02:17:21 +03:00
Damien Elmes
2cba721702
formatting and debug statement tweak
2020-07-24 11:57:37 +10:00
Damien Elmes
1b441f5050
fix pylint failing in CI
2020-07-21 16:16:34 +10:00
Damien Elmes
86fc7446b0
protect against exception on initial recording wait
2020-07-21 16:07:58 +10:00
Damien Elmes
3337c96fdb
trigger recording permission on newer macOS SDKs
2020-07-21 15:54:04 +10:00
kelciour
422e313c16
Replace mpv "idle" property with "end-file" event
2020-06-27 03:46:40 +03:00
kelciour
610f9eb236
Replace default mpv quit keybindings if mpv version is >= 0.30
...
4614d432a8
2020-06-27 03:46:40 +03:00
Damien Elmes
ef55c0a2ee
remove the script-message commands that older mpv version don't support
...
https://github.com/ankitects/anki/pull/671#issuecomment-647798343
2020-06-23 14:30:42 +10:00
Damien Elmes
c3e007f069
remove mpv keybindings on init
...
On a machine here, they cause the following error:
raise MPVCommandError("%r: %s" % (message["command"], e))
aqt.mpv.MPVCommandError: ['keybind', 'q', 'stop']: invalid parameter
2020-06-22 13:22:57 +10:00
kelciour
d64c26f20a
Replace deprecated "idle" event with "idle-active" property
2020-06-20 02:04:35 +03:00
kelciour
9aee8085e0
Disable OSC idle message
2020-06-20 02:04:34 +03:00
kelciour
ae533fce71
Replace default mpv "quit" keybindings with "stop"
...
https://github.com/mpv-player/mpv/blob/master/etc/input.conf
2020-06-20 02:04:34 +03:00
Damien Elmes
5f2987d0f8
allow input.conf in Anki data folder
...
https://anki.tenderapp.com/discussions/beta-testing/1964-anki-2128-alpha#comment_48382756
2020-06-09 10:26:25 +10:00
Damien Elmes
d04699ad06
try mpv on Windows again
...
https://github.com/ankitects/anki/pull/621
2020-05-27 09:21:41 +10:00
Damien Elmes
961833a137
avoid mention of pip
2020-05-05 16:30:22 +10:00
evandrocoan
0006269c01
Used showWarning asking the user to install pyaudio
2020-05-05 00:00:48 -03:00
evandrocoan
b671c8e627
Fix missing pyaudio blocking Anki from running
...
https://github.com/ankitects/anki/pull 606
Remove pyaudio as mandatory dependency
2020-05-04 13:44:12 -03:00
Damien Elmes
84eaf43525
reduce the chances of a race condition in mplayer code
...
Not perfect, it may still happen.
https://anki.tenderapp.com/discussions/ankidesktop/39832-an-error-occurred-audio
2020-03-23 19:15:32 +10:00
Damien Elmes
0ecc189a9b
fix audio getting stuck (2/2)
2020-03-15 09:34:04 +10:00
Damien Elmes
f30853f5ed
fix audio getting stuck (1/2)
...
The problem was caused by stop() doing a spin loop on the main
thread waiting for the completion signal. This prevented Qt's run
loop from executing, and so the completion signal was never delivered,
meaning longer files would time out.
Fixed by reworking the code so that stop() does not block at all -
instead it just sets the termination flag, and AVPlayer does not
unset current_player. Then when the completion callback fires, it
can advance to the next file.
TTS code still needs updating, and the lock should be safe to remove
as the start/stop logic is all on the main thread.
2020-03-15 09:26:31 +10:00
Damien Elmes
8845b05933
make sure audio queue is cleared when transitioning between cards
...
https://anki.tenderapp.com/discussions/beta-testing/1846-anki-2122-beta#comment_48150139
2020-03-14 20:04:40 +10:00
Damien Elmes
aad491dbb9
possible fix for invalid handle issue
...
https://anki.tenderapp.com/discussions/ankidesktop/39346-cant-add-audio-on-flash-drive
2020-03-14 18:53:43 +10:00
Alan Du
f8c22499cb
Monkeytype qt/aqt/sound.py
2020-03-01 10:16:08 -05:00
Damien Elmes
8c0d4c8059
restore mpv/mplayer missing warning that got lost in the av changes
...
and ensure the UI doesn't get temporarily stuck after the command fails
2020-02-29 21:20:08 +10:00
Damien Elmes
db69f84c0a
interrupt current audio when autoplay off
2020-02-25 17:49:06 +10:00
Damien Elmes
32b38bf26d
ensure Anki starts on Windows systems that don't have TTS installed
2020-02-25 16:25:17 +10:00
Damien Elmes
598226a5c0
possible fix for race conditions in the sound code
...
https://anki.tenderapp.com/discussions/ankidesktop/39030-erro-ao-adicionar-arquivo-de-udio
the lock should at least ensure _process doesn't disappear in the
middle of our logic, and the longer wait should reduce the chances
of .stop() timing out and allowing multiple audio files to play
Not very happy with the current approach, as in the timeout case
you have multiple threads competing to access the same data
2020-02-21 15:14:09 +10:00
Damien Elmes
083e4a0b66
drop the extraneous svg group
2020-01-31 07:23:35 +10:00
Damien Elmes
23c6cafb94
add compat soundLink selector back
2020-01-31 07:01:22 +10:00
Damien Elmes
fb696f3e3b
use SVG for the play icon, and reduce the default size to 40px
2020-01-28 10:11:29 +10:00
Damien Elmes
3b8f851854
fix autoplaying of audio in preview screen, and drop extend_and_play()
2020-01-25 16:02:34 +10:00
Damien Elmes
f6ef553ba5
move strip_av_refs() into anki.sound
2020-01-24 15:48:40 +10:00
Damien Elmes
17ebdfc099
extract and flag AV tags as part of the render process
...
We can now show replay buttons for the audio contained in {{FrontSide}}
without having to play it again when the answer is shown.
The template code now always defers FrontSide rendering, as it wasn't
a big saving, and meant the logic had to be implemented twice.
2020-01-24 11:06:11 +10:00
Damien Elmes
03a8f0e73b
fix mpv failing to load
2020-01-24 07:06:59 +10:00
Damien Elmes
b9ee7f49d8
don't wait as long for player to stop
2020-01-23 17:27:07 +10:00
Damien Elmes
5a79bc69b8
fix audio displaying console window on Windows
2020-01-23 17:27:07 +10:00
Damien Elmes
0ad6e8b58e
make pylint happy
2020-01-22 15:37:58 +10:00
Damien Elmes
cfa0f65311
add a hook for when playback begins
2020-01-22 14:41:32 +10:00
Damien Elmes
6af7933084
make .command() behave the same way for mplayer and mpv
2020-01-22 14:11:25 +10:00
Damien Elmes
be3393fcb4
simplify taskman, and add .run_on_main()
2020-01-22 14:09:51 +10:00
Damien Elmes
f92bb55c25
add option in prefs to hide replay audio buttons
2020-01-21 21:00:17 +10:00
Damien Elmes
19b3a15146
formatting fixes
2020-01-21 20:39:25 +10:00
Damien Elmes
ccd7150136
fix mpv args
...
https://anki.tenderapp.com/discussions/ankidesktop/38186-mpvprocesserror-unable-to-start-process
2020-01-21 19:29:50 +10:00
Damien Elmes
5351a5f396
compare only on rank, as voices may be subclassed
2020-01-21 18:33:14 +10:00
Damien Elmes
84711f8fe2
add Windows TTS support
2020-01-21 17:34:47 +10:00
Damien Elmes
7b3d701ad5
add replay buttons to reviewing screen
2020-01-21 14:47:03 +10:00
Damien Elmes
7504ef6857
make sure we don't mutate list passed to play_from_tags()
2020-01-21 14:43:33 +10:00
Damien Elmes
2ac86ac400
add file-based TTS say implementation as well
2020-01-21 13:21:43 +10:00
Damien Elmes
c713683f63
add rank handling to TTS; parse TTS args in get_av_tags()
2020-01-21 12:41:37 +10:00
Damien Elmes
66e277e44b
more TTS and sound work
...
- use provided language and voices when playing on Mac
- fix hang in waiting for termination
- allow players to return a rank for a given tag,
which will allow for the best matching player to be chosen
depending on the context (eg, prioritize one player for videos,
one tts player for certain voices, etc)
2020-01-21 11:34:25 +10:00
Damien Elmes
d4d16d35a8
spawn a new slave mode mplayer for each file
...
This solves a few problems:
- We no longer need to write temporary files to disk, as files
passed on the command line with non-Latin text can be read by mplayer.
- We no longer need to deal with mplayer processes left around in
the background that have failed to terminate.
- We don't need to deal with the added complexity that comes with
polling mplayer's status output to determine when the file has finished
playing.
Also add seek_relative(), toggle_pause() and shutdown() as optional
methods on AVPlayer.
2020-01-21 08:55:15 +10:00
Damien Elmes
01f3fd06d6
support interrupting say; fix race in simple player
2020-01-21 07:28:19 +10:00
Damien Elmes
1beae4f858
pass task manager in instead of creating a new one
2020-01-21 06:49:09 +10:00
Damien Elmes
0b5e22253b
add .stop() to mpv
2020-01-21 06:45:32 +10:00
Damien Elmes
a6e6ffae06
get mpv slave mode working with new API
...
Also move the mpv-specific hooks into AVPlayer
2020-01-20 22:01:38 +10:00
Damien Elmes
d9c240afa2
minor tidyup to sound.py
2020-01-20 21:03:22 +10:00
Damien Elmes
7900f68051
don't need allSounds/stripSounds in qt's sound.py
2020-01-20 20:13:01 +10:00
Damien Elmes
caac4527e9
add a proof of concept TTS implementation on Mac
2020-01-20 20:08:19 +10:00
Damien Elmes
707ac587ec
rework the audio player API and add a simpler player implementation
...
- the new API operates on AVTags so it can support TTS as well as
audio files
- added a simple "run for each file" implementation for mpv and mplayer.
- will need to test handling of unicode filenames on Windows
- the old mpv and mplayer code is currently not active
2020-01-20 20:07:11 +10:00
Damien Elmes
5084438a0b
we can depend on pyaudio being available now that the code is in qt/
2020-01-20 19:21:24 +10:00
Damien Elmes
cab572b63c
remove _hook/_filter suffix
2020-01-15 16:53:24 +10:00
Damien Elmes
89fce1f6b7
migrate addHook/remHook calls
2020-01-15 13:49:26 +10:00
Damien Elmes
660685375f
migrate most of the remaining runHook() calls
2020-01-15 12:46:53 +10:00
Damien Elmes
662eb53e6a
switch to classes for hooks
...
This allows us to add a docstring to .append() so users can see
the names of the arguments that are being passed, and means we
don't have to remember to prepend run_ when calling a hook.
2020-01-14 08:54:07 +10:00
Damien Elmes
4bb3d7a958
add separate file for gui hooks
2020-01-13 14:38:05 +10:00
Damien Elmes
5876866565
tweaking the folder names again
...
hopefully that's the last of it
2020-01-03 07:48:38 +10:00