0
0
Prompt Engineering / GenAIml~10 mins

Text-to-speech generation in Prompt Engineering / GenAI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the text-to-speech library.

Prompt Engineering / GenAI
import [1]
Drag options to blanks, or click blank then click option'
Apandas
Bnumpy
Cgtts
Dmatplotlib
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated libraries like numpy or pandas.
Misspelling the library name.
2fill in blank
medium

Complete 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'
ATrue
B'Hello, world!'
C12345
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Passing numbers or boolean values instead of a string.
Forgetting to put quotes around the text.
3fill in blank
hard

Fix 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'
Aexport
Bwrite
Crecord
Dsave
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names like write or export.
Forgetting parentheses after the method name.
4fill in blank
hard

Fill 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'
Aplaysound
Bos
Csys
Dpygame
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated modules like os or sys.
Using pygame without proper initialization.
5fill in blank
hard

Fill 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'
A'English'
B'Spanish'
C'French'
D'German'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up language codes and names.
Using unsupported language names.