Spaces:
Runtime error
Runtime error
import gradio as gr | |
import transformers | |
import librosa | |
import os | |
import soundfile as sf | |
pipe = transformers.pipeline( | |
model='fixie-ai/ultravox-v0_5-llama-3_1-8b', | |
trust_remote_code=True, | |
use_auth_token=os.getenv("HF_TOKEN") # relies on Secrets -> HF_TOKEN | |
) | |
def chat_with_voice(audio_file): | |
audio, sr = librosa.load(audio_file, sr=16000) | |
turns = [ | |
{ | |
"role": "system", | |
"content": "You are a friendly and helpful character. You love to answer questions for people." | |
}, | |
] | |
output = pipe({'audio': audio, 'turns': turns, 'sampling_rate': sr}, max_new_tokens=30) | |
return output[0]['content'] | |
demo = gr.Interface(fn=chat_with_voice, | |
inputs=gr.Audio(source="upload", type="filepath"), | |
outputs="text", | |
title="Ultravox Voice Chat") | |
demo.launch() | |