Commit Graph

45 Commits

Author SHA1 Message Date
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