Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

sound not working, mp3 file has bug #202

Open
storeberry opened this issue Feb 6, 2022 · 18 comments
Open

sound not working, mp3 file has bug #202

storeberry opened this issue Feb 6, 2022 · 18 comments

Comments

@storeberry
Copy link

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):

  • OS: Windows 11
  • Anki Version ⁨2.1.40 (cf446733)⁩, Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
  • Chinese Support Version v0142

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
Copy link

gdelmee commented Mar 25, 2022

I have the same issue.

  • OS: WIndows 10
  • Anki Version ⁨2.1.49 (dc80804a)⁩, Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
  • Chinese Support Redux v0142

@gdelmee
Copy link

gdelmee commented Mar 31, 2022

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

@gdelmee
Copy link

gdelmee commented Oct 1, 2022

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
Copy link

hi

Me too I've recently this trouble !

How to do ?

@Kruller08
Copy link

I have the same issue.

OS: MacOS monterey

Anki: Version ⁨2.1.44 (b2b3275f)⁩

@frixo3190
Copy link

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

pndurette/gTTS#363

frixo3190 added a commit to frixo3190/chinese-support-redux that referenced this issue Oct 6, 2022
@frixo3190
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

proto455 commented Oct 9, 2022

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
Copy link

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
Copy link

frixo3190 commented Oct 14, 2022 via email

@jwolf112
Copy link

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
Copy link

kaysik commented Oct 22, 2022

'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<YOUR USER>\AppData\Roaming\Anki2<YOUR PROFILE>\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
Copy link

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
Copy link

IrIougER commented Nov 4, 2022

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

@jw-00000
Copy link

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:

  • the collection.media folder at /Users/USERNAME/Library/Application Support/Anki2/PROFILE_NAME/collection.media
  • the tts.py file at /Users/USERNAME/Library/Application Support/Anki2/addons21/1128979221

for Windows:

  • the collection.media folder at C:\Users\USER_NAME\AppData\Roaming\Anki2\PROFILE_NAME\collection.media\
  • the tts.py file at C:\Users\USER_NAME\AppData\Roaming\Anki2\addons21\1128979221

[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 :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests