Chapter 9 questions

Use this topic for any question about Chapter 9 of the course.

Hello Everyone!

I think something is missing in the Sharing demos with others - Hugging Face Course, namely imports and defining the function:


" Creating a simple demo using Blocks" " Flip Text! Start typing below to see the output." on the course webpage does not work for me.

It works fine now. But the code for musical notes needs to be changed at the very end so that gr.Textbox(type=“number”, value=1, label=“Duration in seconds”) becomes gr.Textbox(type=“text”, value=1, label=“Duration in seconds”),

I am trying the first Gradio example. When I use GoogleCoLab it works fine. But when I use Sagemaker Studio Lab, nothing appears. Do I need to do something else? The instructions state that when using a notebook, the Gradio display should occur inline. It does with GoogleCoLab, but not with Studio Lab.

There are two errors in the examples, probably related to API changes:

Microphone example:

# old:
mic = gr.Audio(source="microphone", type="numpy", label="Speak here...")
# results in TypeError: Audio.__init__() got an unexpected keyword argument 'source'

# solution
mic = gr.Audio(sources=["microphone"], type="numpy", label="Speak here...")

Tone generation example:

# old
gr.Textbox(type="number", value=1, label="Duration in seconds"),
# gives ValueError: `type` must be one of "text", "password", or "email".

# solution
gr.Number(value=1, label="Duration in seconds"),

There’s also a related error in the speech recognition example which I could not quickly resolve.

1 Like

There is a typo in the section “Handling multiple inputs and outputs”, which is
“a list of output coponents, each component corresponds to a returned value.”