jdlorimer / chinese-support-redux

Anki add-on providing support for Chinese study
https://ankiweb.net/shared/info/1128979221
GNU General Public License v3.0
100 stars 50 forks source link

sound not working, mp3 file has bug #202

Open storeberry opened 2 years ago

storeberry commented 2 years ago

Describe the bug When adding new vocab using the extension, the downloaded soundfiles (baidu) have a bug so they cannot be played. I just got this error this week, the vocab I added before (2nd Dec 21) do not show this problem (and I did a two month break in between). I tried to change to google and see if the bug remained, but then I lost the automatic adding by using "tab" altogether (restarting the program did not help). Updated driver, tried headphones, but in the end I opend the downloaded .mp3 file with the installed player (groove music) and I got an error (0xc00d36c4), VLC media player does not play sound as well. The problem does not occur for previously downloaded files. Tried checking for updates (Anki, add-on), but both did not have any available.

To Reproduce

  1. Add vocabulary using automatic grabber with "baidu" tts, all fields are filled
  2. open card to learn the word
  3. do not hear sound

Expected behavior Add sound that can be played when repeating vocab.

Screenshots The windows error I get when manually opening the .mp3 files is 0xc00d36c4. The files are (or look) however the same as before.

Specs (please complete the following information):

Additional context The first time I tried to write a report, if anything is unclear, I'll be happy to provide more info! I love the add-on and it really helps me with my chinese language goals. The missing sound is making me quite desprate, I tried to search for an answer but did not find it. I'll be immensly greatful for help!

gdelmee commented 2 years ago

I have the same issue.

gdelmee commented 2 years ago

Switching from Baidu to Google, the MP3 is fine. It seems the issue comes from Baidu's integration.

gdelmee commented 2 years ago

Update on this issue. As of now, neither Baidu or Google are working.

For Google, files are empty, for Baidu, the file is broken:

image

image

frixo3190 commented 2 years ago

hi

Me too I've recently this trouble !

How to do ?

Kruller08 commented 2 years ago

I have the same issue.

OS: MacOS monterey

Anki: Version ⁨2.1.44 (b2b3275f)⁩

frixo3190 commented 2 years ago

Thé trouble is due to an issue of gtts librairy used by the plugin

https://github.com/pndurette/gTTS/issues/363

frixo3190 commented 2 years ago

ok, i've found a solution to make audio working, it's because Google Tlanslate gTTS (library) is block when use CN URL, i just replace .cn by .com (or .fr) and it's work !

Kruller08 commented 2 years ago

Thank you frixo for the solution. Can you describe how to change the url from .cn to .com please? I don’t know how to do it.

frixo3190 commented 2 years ago

you're on Mac, I'm on Windows. So the file localisation isn't the same. I suppose you will found a folder called Anki in your library (the library in your user folder (it's perhaps a hidden folder)) in Anki folder you've an AddOn Folder and then you will find the folder with the IF of ChineeseAddOn. In this folder find the file names : tts.py, and go to line 56 , replace cn by com

it looks like that : def get_google(self): tts = gTTS(self.text, lang=self.lang, tld='com') try:

On Windows the file is here : C:\Users\YOUR_USER_NAME\AppData\Roaming\Anki2\addons21\1128979221

Kruller08 commented 2 years ago

Thank you so much, it worked!

For Mac users the file localisation is ~/Library/Application Support/Anki2 folder. It is a hidden folder so you will need to option-click on the "go" menu in finder. Click on library and locate the Application Support folder. In there you will find the Anki2 folder.

proto455 commented 2 years ago

Still cannot get audio to play. I replaced my tts.py 'cn' to 'com' but still no luck. On MacOS Monterey 12.5.1. Neither Baidu or Google audio working.

When I go to ->Tools->Check Media

I get the following error:

Missing files: ⁨1⁩ Unused files: ⁨0⁩

The following files are referenced by cards, but were not found in the media folder: Missing: 你好_google_zh-CN.mp3

But when I go to my /Users/proto455/Library/Application Support/Anki2/User 1/collection.media

I am able to find the file in question, however it will not play via VLC or any other application.

Sorry if fix is obvious, new here and really would love to get this working

souchi007 commented 2 years ago

Hello ! Thank you for the help, I had the same problem but now it works thank to you. I use Google audio. At first I changed the 'cn' to 'com' and it still didn't work. But then I changed it to 'fr' and now it works, thanks !

frixo3190 commented 2 years ago

Great!

Le ven. 14 oct. 2022, 14:11, souchi007 @.***> a écrit :

Hello ! Thank you for the help, I had the same problem but now it works thank to you. I use Google audio. At first I changed the 'cn' to 'com' and it still didn't work. But then I changed it to 'fr' and now it works, thanks !

— Reply to this email directly, view it on GitHub https://github.com/luoliyan/chinese-support-redux/issues/202#issuecomment-1278922862, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFTRHEQGMKNYAAUJMWX6HJ3WDFEWNANCNFSM5NVZIJBQ . You are receiving this because you commented.Message ID: @.***>

jwolf112 commented 2 years ago

Hello - I was experiencing the same issue as the original poster after updating Anki to 2.1.54 Qt5 on Windows. For me, the advice on this thread allowed me to resolve the issue, but only when using Speech Engine "Google Mandarin (Taiwan)", not "Google Mandarin (PRC)" or "Baidu Translate". I just wanted to note that in case in helps anyone else.

Thank you all who helped find a work around for this issue!

kaysik commented 2 years ago

'cn'->'com' fix only works for new cards (as in new text). Initially I thought changing 'cn' to 'com' as above did not work because it didn't fix my broken cards. However it does work for NEW cards (which generate a new unique file name), but does NOT fix already broken ones. Even if you delete the text in your cards audio field, and have it re-generate the audio, the old corrupted file is still found will still be used - it doesn't actually generate a new audio file if it can find an old one.

So to fix old, already broken cards you must delete the old broken files. On windows they can be found here:

C:\Users\\AppData\Roaming\Anki2\\collection.media\

(if, like me you had quite a few busted ones you can just sort by size and delete anything with a size of 0).

Once deleted the sounds can now be re-generated and this time they'll work.

BeorTheOld commented 2 years ago

I recently moved to Taiwan and this is when I first noticed the problem, it wont work even if I delete all the 0 kbs files and change the cn to com, however I used a vpn to say I was in America and the files work now.

IrIougER commented 2 years ago

I've followed the advice in this thread. Still cannot get the sound to work.

jw-00000 commented 1 year ago

Changing to .com worked for me. Note though that you need to remove the old (corrupt) files! And then of course regenerate the new ones.

The procedure is thus as follows (some tips below; read everything before doing it):

  1. Quit Anki.
  2. In the collection.media folder [1], copy the names of all files of 0 bytes (= the corrupt files) and save them somewhere. [2]
  3. Then, remove all files of 0 bytes.
  4. In tts.py [1], replace cn with com on line 56.
  5. Restart Anki.
  6. Search for all notes referring to the old, corrupt files, and remove the reference to the old file. [2]
  7. Regenerate the files, using the menu item "Chinese > Bulk Fill > Sound" in Anki.

[1] You can find these folders at:

for macOS:

for Windows:

[2] Here's a trick to do these steps easily using the command line on macOS.

Execute the following commands in the terminal:

cd "/Users/USERNAME/Library/Application Support/Anki2/PROFILE_NAME/collection.media"
find . -size 0 | sed 's/\.\///g' | tr '\n' '|' | sed -e 's/^/\\\[sound:\(/' -e 's/\|?$/\)\\\]/'

(The first command goes to the right folder. The second command searches the names all corrupt files, i.e. files with size 0 bytes, and then removes the ./ prefix, concatenates them into with |, and adds a something in front and at the end.)

This should generate an output like

\[sound:(a.mp3|b.mp3|c.mp3)\]

Copy this.

For step 2, you can delete the files in the Finder by sorting by size and deleting the files with size 0 bytes.

For step 6, in Anki, go to the Browse window, and to the menu Notes > Find and Replace... Paste the output from above in the "Find" box, and leave "Replace With" empty. Make sure to select "Treat as regular expression" and apply this replacement to all notes.

Note: on Linux, the same commands should work in the right folder.

I'd advise to make a back-up of your Anki profile before executing these commands :)