Sreekumar1608 commited on
Commit
fc6fb92
·
1 Parent(s): e321dc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -1,18 +1,17 @@
1
  import gradio as gr
2
  import openai
3
- import winsound
4
  from elevenlabslib import *
5
  from pydub import AudioSegment
6
  from pydub.playback import play
7
  import io
8
- import config
9
 
10
  openai.api_key = "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"
11
  api_key = "929b67c6e533e94018a438d70c960b60"
12
  from elevenlabslib import ElevenLabsUser
13
  user = ElevenLabsUser(api_key)
14
 
15
- messages = ["You are an advisor. Please respond to all input in 50 words or less."]
16
 
17
  def transcribe(audio):
18
  global messages
@@ -25,7 +24,7 @@ def transcribe(audio):
25
  response = openai.Completion.create(
26
  engine="text-davinci-003",
27
  prompt=messages[-1],
28
- max_tokens=80,
29
  n=1,
30
  stop=None,
31
  temperature=0.5,
@@ -34,7 +33,7 @@ def transcribe(audio):
34
  system_message = response["choices"][0]["text"]
35
  messages.append(f"{system_message}")
36
 
37
- voice = user.get_voices_by_name("Antoni")[0]
38
  audio = voice.generate_audio_bytes(system_message)
39
 
40
  audio = AudioSegment.from_file(io.BytesIO(audio), format="mp3")
@@ -47,10 +46,9 @@ def transcribe(audio):
47
 
48
  iface = gr.Interface(
49
  fn=transcribe,
50
- inputs=gr.Audio(source="microphone", type="filepath", placeholder="Please start speaking..."),
51
  outputs="text",
52
- title="🤖 My Desktop ChatGPT Assistant 🤖",
53
- description="🌟 Please ask me your question and I will respond both verbally and in text to you...",
54
  )
55
 
56
  iface.launch()
 
1
  import gradio as gr
2
  import openai
 
3
  from elevenlabslib import *
4
  from pydub import AudioSegment
5
  from pydub.playback import play
6
  import io
7
+ import winsound
8
 
9
  openai.api_key = "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"
10
  api_key = "929b67c6e533e94018a438d70c960b60"
11
  from elevenlabslib import ElevenLabsUser
12
  user = ElevenLabsUser(api_key)
13
 
14
+ messages = ["Respond with voice"]
15
 
16
  def transcribe(audio):
17
  global messages
 
24
  response = openai.Completion.create(
25
  engine="text-davinci-003",
26
  prompt=messages[-1],
27
+ max_tokens=60,
28
  n=1,
29
  stop=None,
30
  temperature=0.5,
 
33
  system_message = response["choices"][0]["text"]
34
  messages.append(f"{system_message}")
35
 
36
+ voice = user.get_voices_by_name("Bella")[0]
37
  audio = voice.generate_audio_bytes(system_message)
38
 
39
  audio = AudioSegment.from_file(io.BytesIO(audio), format="mp3")
 
46
 
47
  iface = gr.Interface(
48
  fn=transcribe,
49
+ inputs=gr.Audio(source="microphone", type="filepath"),
50
  outputs="text",
51
+ title="Voice Assistant",
 
52
  )
53
 
54
  iface.launch()