File size: 937 Bytes
8d59b1d
 
 
 
 
 
 
 
 
 
 
 
 
db80382
8d59b1d
 
 
abc2da4
 
 
db80382
8d59b1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
import os

import openai
from dotenv import load_dotenv
load_dotenv()
openai.api_key=os.environ["OPENAI_API_KEY"]

import gradio as gr
from langchain.llms import OpenAI
from interface import AudioInterface
interface = AudioInterface()

def process(filepath):
    print(filepath)
    audio = open(filepath,"rb")
    transcript = openai.Audio.transcribe("whisper-1",audio)
    llm = OpenAI(temperature=1)
    #print(llm(transcript["text"]))
    interface.speak(llm(transcript["text"]))
    return llm(transcript["text"])

demo = gr.Interface(
    fn=process,
    inputs=gr.Audio(source="microphone",type="filepath"),
    outputs="text")
demo.launch()


"""

from dotenv import load_dotenv
load_dotenv()

from interface import AudioInterface
from agents import SmartChatAgent

interface = AudioInterface()
agent = SmartChatAgent()

while True:
    text = interface.listen()
    response = agent.run(text)
    interface.speak(response)


"""