Spaces:
Runtime error
Runtime error
import gradio as gr | |
def formatted_message(audio_length, audio_class, userText) | |
prefix = '''You are going to act as a magical tool that allows for humans to communicate with non-human entities like | |
rocks, crackling fire, trees, animals, and the wind. In order to do this, we're going to provide you a data string which | |
represents the audio input, the source of the audio, and the human's text input for the conversation. | |
The goal is for you to embody the source of the audio, and use the length and variance in the signal data to produce | |
plausible responses to the humans input. Remember to embody the the source data. When we start the conversation, | |
you should generate a "personality profile" for the source and utilize that personality profile in your responses. | |
Let's begin:''' | |
suffix = f'''Source: {audio_class} | |
Length of Audio in Seconds: {audio_length} | |
Human Input: {userText} | |
{audio_class} Response:''' | |
template = prefix + suffix | |
response = call_api(template) | |
return response | |
def call_api(message): | |
""" | |
response = requests.get(f'{api}?q={message}') | |
if response.status_code == 200: | |
return str(response.text).split('\n', 2)[2] | |
else: | |
return Sorry, I'm quite busy right now, but please try again later :) | |
""" | |
return message | |
demo = gr.Interface( | |
call_api, | |
gr.Audio(source="microphone"), | |
gr.Audio(), | |
).launch(debug=True) | |