You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I came across this wonderful project during my language-learning joruney. I gave it a try and it worked just fine until I tried to add .mp3 files to my cards. I was testing the whole thing of creating decks and cards with the help of chat gpt.
This is what shows up when I try to use the deck in AnkiDroid:
This is the folder that contains the python script "createAnkiDeckTest.py":
I created the deck with the .zip extention to check its contents and this is what I found:
The media file only contains a json with the names of the audio files
How can I succesfully package the audio files soo I can use them in my cards in AnkiDroid? Thank you for your time!
This is my code:
importgenankiimportos# Define the model (card type) for the deckmy_model=genanki.Model(
1600000000,
'Simple Model',
fields=[
{'name': 'Front'},
{'name': 'Back'},
{'name': 'Audio'},
],
templates=[
{
'name': 'Card 1',
'qfmt': ''' <div style="text-align: center; font-size: 24px;"> {{Front}} <br> <audio controls> <source src="{{Audio}}" type="audio/mpeg"> Your browser does not support the audio element </audio> </div> ''',
'afmt': ''' <div style="text-align: center; font-size: 24px;"> {{Back}} <br> <audio controls> <source src="{{Audio}}" type="audio/mpeg"> Your browser does not support the audio element </audio> </div> ''',
},
],
)
# Define the deckmy_deck=genanki.Deck(
44584545,
'My First Deck',
)
# Define the notes (cards) to add to the decknotes= [
genanki.Note(
model=my_model,
fields=['Hello', 'Bonjour', 'Avoir.mp3'], # Ensure filenames matchtags=['greetings'],
),
genanki.Note(
model=my_model,
fields=['Goodbye', 'Au revoir', 'Associez.mp3'], # Ensure filenames matchtags=['farewell'],
),
]
# Add notes to the deckfornoteinnotes:
my_deck.add_note(note)
# Create the package (export file)my_package=genanki.Package(
my_deck,
)
# Specify media files with correct relative pathsmy_package.media_files= [
'Avoir.mp3',
'Associez.mp3',
]
# Save the package to an .apkg filemy_package.write_to_file('my_deck.zip')
print("Deck has been created and saved as 'my_deck.apkg'.")
The text was updated successfully, but these errors were encountered:
Then, set the MyMedia field on your card to [sound:sound.mp3] for audio and for images (from the readme) I have an issue where my audio are still not getting exported though.
Hello! I came across this wonderful project during my language-learning joruney. I gave it a try and it worked just fine until I tried to add .mp3 files to my cards. I was testing the whole thing of creating decks and cards with the help of chat gpt.
This is what shows up when I try to use the deck in AnkiDroid:
This is the folder that contains the python script "createAnkiDeckTest.py":
I created the deck with the .zip extention to check its contents and this is what I found:
The media file only contains a json with the names of the audio files
How can I succesfully package the audio files soo I can use them in my cards in AnkiDroid? Thank you for your time!
This is my code:
The text was updated successfully, but these errors were encountered: