Spaces:
Runtime error
Runtime error
import gradio as gr | |
with gr.Blocks() as demo: | |
model_choice = gr.Dropdown(["openai/whisper-large", "HuggingFaceH4/zephyr-7b-beta"], | |
label="Choose Model", value="openai/whisper-large") | |
input_data = gr.Audio(source="microphone", type="filepath", label="Speak Your Message") # Note: type is now "filepath" | |
output_text = gr.Textbox(label="Transcription and Response") | |
def generate_response(audio_path, model_name): | |
hf_interface = gr.Interface.load(model_name) # Load the model directly from the Hub | |
if model_name == "openai/whisper-large": | |
transcription = hf_interface(audio_path) # Handle transcription | |
else: # Zephyr | |
transcription = hf_interface(audio_path)[0]["generated_text"] # Extract transcription from zephyr | |
response = hf_interface(transcription)[0]["generated_text"] # Get Zephyr's response | |
return transcription, response | |
input_data.change(generate_response, inputs=[input_data, model_choice], outputs=output_text) | |
demo.launch() |