Commit Graph

136 Commits

Author SHA1 Message Date
Damien Elmes
4a7c5b74c1 Log mpv invocation failure for debugging
https://forums.ankiweb.net/t/i-received-this-error-while-reviewing-a-deck-with-cards-that-had-video-mp4/30105
2023-05-11 14:47:23 +10:00
Damien Elmes
0a0d17ff98 Update Python deps
- Black's formatting has changed
- Pylint has introduced a new lint
2023-03-31 14:04:05 +10:00
Abdo
e23036ea8b
Fix packaged audio tools path on Windows (#2419)
There is no audio subfolder as of 2.1.55+
2023-03-06 19:27:08 +10:00
Damien Elmes
d98912ca6b Revert "Probable workaround for mpv failing after a few days on macOS"
This reverts commit fa4fc3e15a.

Issue turned out to be a packaging problem, and this should not be
required as the socket should be held open even if removed.
2022-12-03 23:30:19 +10:00
Damien Elmes
fa4fc3e15a Probable workaround for mpv failing after a few days on macOS
Also fix the certifi bumper: it was supposed to repeat
2022-12-03 22:11:39 +10:00
Damien Elmes
383c890b0d Fix duplicate Anki icons appearing in dock
MPV was previously stored in the MacOS/ folder, which made macOS think
it should have a dock icon.

Fixes #1812
2022-05-26 11:05:36 +10:00
Abdo
f22d8015a6
Add some helper functions to AVPlayer (#1864) 2022-05-13 13:08:05 +10:00
RumovZ
9c54f85be6
Import submodules directly (#1662)
* Use submodule imports in aqt

* Use submodule imports in pylib

* More submodule imports in pylib

These required removing some direct imports to get rid of import cycles.
2022-02-13 13:40:47 +10:00
RumovZ
6c8cdc0a0c
Keep cwd and pass dir to player subprocess instead (#1656) 2022-02-11 10:35:48 +10:00
RumovZ
9936f6f7d1
Only warn once about missing av player (#1592) 2022-01-16 13:46:01 +10:00
Damien Elmes
db804d9544 macOS audio tools no longer reside in audio/ subfolder
+ fix error message broken by automated .tr() syntax change
2021-12-09 17:33:46 +10:00
Damien Elmes
0de24122ad implement a basic native macOS audio recorder
This was motivated by the fact that recording was crashing on the native
M1 build. That ended up being mostly a PEBKAC problem - turns out the
Mac Mini has no built-in microphone 🤦.

I still thinks this has some value though - it doesn't crash in such
cases, and probably doesn't suffer from the problem shown in this thread
either:

https://forums.ankiweb.net/t/anki-crashes-when-trying-to-record-on-mac/14764

For now, this is only enabled when running on arm64. If it turns out to
be reliable, it could be offered as an option on amd64 as well.
2021-12-07 18:48:24 +10:00
Damien Elmes
ebad6ad379 update platform checks (eg isWin -> is_win) + devMode 2021-11-25 09:06:16 +10:00
Damien Elmes
a447c3eb12 fix broken startup on macOS due to incorrect mpv path 2021-10-30 09:14:43 +10:00
Damien Elmes
ba86502a27 tweaks for Windows package
- move audio tools into subfolder
- add buildmanifest.py
2021-10-29 18:11:28 +10:00
Damien Elmes
dc56b43c32 show warning instead of crashing when recording on darwin-arm64 2021-10-29 14:43:59 +10:00
Damien Elmes
83af294a8c rename some of the files in aqt/qt/ 2021-10-29 13:54:24 +10:00
Aristotelis
2d1c058106
Maintain compatibility with PyQt5 add-ons in PyQt6 builds (#1440)
* Alias PyQt5 to PyQt6 on PyQt6 builds

Restores basic compatibility with PyQt5 add-ons

* Register QtCore early to work around sip error

* Monkey-patch unscoped enums that are in use by add-ons back in

Enums whose namespace moved with PyQt6 were determined using the tooling in https://github.com/qutebrowser/qutebrowser/issues/5904

Relevant enums for the Anki add-on ecosystem were found by grepping through all AnkiWeb add-ons and a selection of GitHub-released add-ons.

* Add full Qt.Key namespace

Maintains compatibility with add-ons that allow specifying key bindings via Qt.Key enums

* Reintroduce PyQt6.Qt as an alias for QtCore.Qt

* Alias classes shifted from QtWidgets to QtGui

* Add missing enums

Adds ≈200 enums that were missed during the initial grep

* Map exec_ calls to exec

* Tweak section headers

* Fix QtWebEngineWidgets imports failing due to delayed import

Addesses: "QtWebEngineWidgets must be imported before a QCoreApplication instance is created"

* Register additional aliases for top-level Qt modules

Given how we have had to deal with side-effects when not registering other aliased imports ahead of time, it seems safer to also register the remaining few with sys.modules.

* Handle calls to deprecated PyQt resource API graciously

* Create QtWebEngineWidgets aliases for classes moved to QtWebEngineCore

* Alias QShortcut

* Restore QWebEnginePage.view()

* Alias sip to PyQt6.sip

* Alias QtCore.QRegExp to QtCore.QRegularExpression

* Restructure aqt.qt into package

Pre-requirement for aliasing the PyQt5.Qt namespace correctly.

Should hopefully also make it easier to keep an overview as Qt-compat-related modules were proliferating.

* Properly alias PyQt5.Qt

PyQt5.Qt used to serve as a common namespace for all Qt classes, not just QtCore.Qt.*

While this changes does not make all classes accessible via PyQt5.Qt, it does so for the most important Qt submodules, which should cover most add-on breakages.

* Simplify Qt resource system legacy handling

* Also alias PyQt6.Qt

Covers imports of the form `from PyQt5 import import Qt` (due to previous aliasing of PyQt5 to PyQt6)

* Add missing enums

Better approach to grepping through add-ons yielded additional hits

* Run formatters

* Satisfy pylint
2021-10-28 19:57:42 +10:00
Damien Elmes
5a8e064a7d updated package scripts 2021-10-28 18:46:45 +10:00
Damien Elmes
52642d693b drop PyAudio support
I do not recall anyone reporting that it worked better than the Qt
implementation for them, and the lack of recent wheels on PyPI is a pain.
We can always add it back in the future if enough people come out of
the woodwork to report they were using it.
2021-10-15 13:15:16 +10:00
Damien Elmes
7962c8107f qt recording support for qt6
+ fix inefficient bytes concatenation
2021-10-15 12:57:19 +10:00
Damien Elmes
a7812dedc0 switch to new-style PyQt scoped enums and Qt6
The enum changes should work on PyQt 5.x, and are required in PyQt 6.x.
They are not supported by the PyQt5 typings however, so we need to run
our tests with PyQt6.
2021-10-15 12:57:19 +10:00
Damien Elmes
4d0a915610 move QtAudioInputRecorder into separate PyQt5-only file
New API required for PyQt6.
2021-10-15 10:47:53 +10:00
Damien Elmes
e357dbf6b3 use Qt search path instead of resource system
Means URLs like :/icons/foo.jpg should become icons:foo.jpg

This is part of the prep work for a PyQt6 update. PyQt6 has dropped
pyrcc, so we can longer generate the icons_qrc.py file we did previously.

Qt Designer expects us to use the resource system, so we continue to
generate the icons.qrc file to make editing the UI files easier. But at
runtime, we no longer use that file.
2021-10-12 16:17:08 +10:00
Damien Elmes
b9251290ca run pyupgrade over codebase [python upgrade required]
This adds Python 3.9 and 3.10 typing syntax to files that import
attributions from __future___. Python 3.9 should be able to cope with
the 3.10 syntax, but Python 3.8 will no longer work.

On Windows/Mac, install the latest Python 3.9 version from python.org.
There are currently no orjson wheels for Python 3.10 on Windows/Mac,
which will break the build unless you have Rust installed separately.

On Linux, modern distros should have Python 3.9 available already. If
you're on an older distro, you'll need to build Python from source first.
2021-10-04 15:05:48 +10:00
Damien Elmes
2a2469e7a2 Revert "Revert "Merge pull request #1364 from evandroforks/fix_unclosed_python_file""
This reverts commit a2ac197fd786b31880c8334735b4a2d6bd76b0bd.

Looks like it wasn't the cause of the previously reported problem:

https://forums.ankiweb.net/t/2-1-48-tts-problem/13587/2
2021-09-27 18:43:16 +10:00
Damien Elmes
cdad1efdcf Revert "Merge pull request #1364 from evandroforks/fix_unclosed_python_file"
This reverts commit c05475a49e54ed7a56bc635e5e5528334d4ba6ac.

Revert "possible fix for reported audio issues"

This reverts commit f00f7f099f.

Reverting in case https://forums.ankiweb.net/t/2-1-48-release-candidate/13268/10
is related to this change. If the issue persists, we'll know this was
not the cause.
2021-09-20 21:39:15 +10:00
Damien Elmes
f00f7f099f possible fix for reported audio issues
https://forums.ankiweb.net/t/2-1-48-release-candidate/13268/6

This is the only area of the sound code that has changed since 2.1.47
2021-09-16 10:27:37 +10:00
evandrocoan
c7cff516e4 Add clone stdin to another _process deletion 2021-09-09 18:36:21 -03:00
evandrocoan
133e22dbe4 Fix ResourceWarning: unclosed file <_io.BufferedWriter name=5>
https://forums.ankiweb.net/t/aqt-sound-py-resourcewarning-unclosed-file-io-bufferedwriter-name-5/13070
2021-09-08 21:02:12 -03:00
Damien Elmes
b9d42af423 add a small .wait() after terminating player process
Avoids python3.8/subprocess.py:942:
ResourceWarning: subprocess 90387 is still running
  _warn("subprocess %s is still running" % self.pid,
2021-08-19 10:33:56 +10:00
kelciour
c950745ab4 keep the internal mpv playlist from growing on
https://forums.ankiweb.net/t/audio-tracks-get-clipped-at-the-end/10289/5
2021-06-10 11:28:57 +03:00
kelciour
63dc301ef0 use 'cycle' command to toggle pause 2021-06-07 01:54:07 +03:00
kelciour
c352314ed8 fix audio is paused unusual
closes #1164
2021-06-07 01:09:44 +03:00
Damien Elmes
be9bbf2157 catch all recording errors; mention permission
https://forums.ankiweb.net/t/i-have-an-error-when-i-try-to-record-of-audio/10483
2021-06-02 12:20:40 +10:00
Damien Elmes
bcb1a2a329 fix 'lame missing' message not being shown
https://forums.ankiweb.net/t/cant-use-voice-recorder/8753
2021-03-29 19:52:30 +10:00
Damien Elmes
b7587cb8d2 update TR references that contain arguments 2021-03-26 14:21:04 +10:00
Damien Elmes
0c338bfd53 update no-arg tr references in qt/ 2021-03-26 13:48:26 +10:00
Damien Elmes
0c59c8b591 fix a bunch of qt typing issues uncovered by the following commit 2021-03-19 19:45:21 +10:00
Damien Elmes
88c002f4eb convert qt strings to f-strings with flynt
Also revealed an incorrect type def in editor.py that mypy wasn't
noticing before :-(
2021-02-11 10:09:06 +10:00
Damien Elmes
6426edb0ac more typing updates 2021-02-02 23:31:55 +10:00
Damien Elmes
a56b09b987 add a bunch of return types 2021-02-01 23:53:23 +10:00
Damien Elmes
322788133b tooltip() instead of print() when no tts tag matches
Can help with debugging user error like an incorrectly-typed language
code. Don't ask me how I know. :-)
2021-01-26 20:37:24 +10:00
Kyle Mills
a0dc33c0e8
typo 2021-01-10 07:18:08 -08:00
Damien Elmes
b30b7c3073 fix qt/ pylints 2021-01-07 16:21:50 +10:00
Damien Elmes
94064b8230 convert setWindowFlags call into helper, and fix invalid variables
"type: ignore" was masking the invalid references to self in places
like showText()
2021-01-07 14:24:49 +10:00
BlueGreenMagick
6224658c0d remove context help button 2021-01-06 22:15:48 +09:00
Damien Elmes
7d1c8c29f9 add a small delay before terminating recording
https://forums.ankiweb.net/t/anki-crashes-periodically-after-clicking-record-audio-button/5824/12
2020-12-21 16:37:28 +10:00
Damien Elmes
019a65efc1 drop QtRecorder driver; rename existing 2020-12-21 15:02:22 +10:00
Ryan Aird
a30064d5e9 Make RT import statement conditional, fix formatting, ignore WinRT for type checking 2020-12-20 19:43:09 -06:00