chan4lk commited on
Commit
a0315da
1 Parent(s): 0a3d291

chat happens

Browse files
Files changed (1) hide show
  1. app.py +23 -9
app.py CHANGED
@@ -66,20 +66,34 @@ def toAudio(text):
66
  return speech
67
 
68
  def clone(audio, file):
 
 
69
  question = toText(audio=audio)
70
  text = extract_text(file.name)
71
  res = extract_answer(question, text)
72
  print(res)
73
  speech = toAudio(res)
74
  sf.write("speech.wav", speech["audio"], samplerate=speech["sampling_rate"])
75
- return "./speech.wav"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
- iface = gr.Interface(fn=clone,
78
- inputs=[gr.Audio(sources="microphone", type='filepath', label='Question from Resume'), gr.File(label="Resume")],
79
- outputs=gr.Audio(label='Says', autoplay=True),
80
- title='Voice Clone',
81
- description="""
82
- whisper
83
- """,
84
- theme = gr.themes.Base(primary_hue="teal",secondary_hue="teal",neutral_hue="slate"))
85
  iface.launch()
 
66
  return speech
67
 
68
  def clone(audio, file):
69
+ if audio is None or file is None:
70
+ return None
71
  question = toText(audio=audio)
72
  text = extract_text(file.name)
73
  res = extract_answer(question, text)
74
  print(res)
75
  speech = toAudio(res)
76
  sf.write("speech.wav", speech["audio"], samplerate=speech["sampling_rate"])
77
+ return "./speech.wav"
78
+
79
+ def start_recording():
80
+ return None
81
+
82
+ with gr.Blocks() as iface:
83
+ with gr.Row():
84
+ audio_input = gr.Audio(sources="microphone", type="filepath", label='Question from Resume')
85
+ file_input = gr.File(label="Resume")
86
+
87
+ output = gr.Audio(label='Says', autoplay=True)
88
+
89
+ inputs = [audio_input, file_input]
90
+
91
+ btn = gr.Button("Submit")
92
+ btn.click(fn=clone, inputs=inputs, outputs=output)
93
+
94
+ audio_input.stop_recording(fn=clone, inputs=inputs, outputs=output)
95
+
96
+ # Add event to start recording after output audio finishes
97
+ output.play(fn=start_recording, outputs=audio_input)
98
 
 
 
 
 
 
 
 
 
99
  iface.launch()