File size: 1,455 Bytes
0bca911
 
cedb35f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0bca911
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0d46620
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)