Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the text-to-speech library.
Prompt Engineering / GenAI
import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated libraries like numpy or pandas.
Misspelling the library name.
✗ Incorrect
The gtts library is used for text-to-speech generation in Python.
2fill in blank
mediumComplete the code to create a text-to-speech object from a string.
Prompt Engineering / GenAI
tts = gtts.gTTS(text=[1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing numbers or boolean values instead of a string.
Forgetting to put quotes around the text.
✗ Incorrect
The text parameter must be a string containing the text to convert to speech.
3fill in blank
hardFix the error in saving the speech audio to a file.
Prompt Engineering / GenAI
tts.[1]('output.mp3')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names like write or export.
Forgetting parentheses after the method name.
✗ Incorrect
The correct method to save the audio file in gtts is 'save'.
4fill in blank
hardFill both blanks to play the saved audio file using Python.
Prompt Engineering / GenAI
import [1] [2].playsound('output.mp3')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated modules like os or sys.
Using pygame without proper initialization.
✗ Incorrect
The playsound module is used to play audio files simply in Python.
5fill in blank
hardFill all three blanks to create a dictionary of language codes and descriptions for TTS.
Prompt Engineering / GenAI
languages = {
'en': [1],
'es': [2],
'fr': [3]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up language codes and names.
Using unsupported language names.
✗ Incorrect
The dictionary maps language codes to their language names for TTS selection.