dschandra commited on
Commit
497eb2a
·
verified ·
1 Parent(s): 83a6bbe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -15,7 +15,7 @@ conversational_pipeline = pipeline("text-generation", model="microsoft/DialoGPT-
15
 
16
  def speech_to_text(audio_file):
17
  """Convert speech in audio file to text using Wav2Vec2"""
18
- audio_input, _ = librosa.load(audio_file, sr=16000)
19
  input_values = processor(audio_input, return_tensors="pt").input_values
20
 
21
  # Perform speech-to-text
@@ -53,12 +53,12 @@ def process_audio(audio_file):
53
  # Create Gradio interface for audio input/output
54
  iface = gr.Interface(
55
  fn=process_audio,
56
- inputs=gr.Audio(type="filepath"), # Updated for Gradio v3.x (type="filepath" for audio input)
57
- outputs=[gr.Textbox(), gr.Audio(type="filepath")], # Updated for Gradio v3.x (type="filepath" for audio output)
58
  live=True,
59
  title="Voice Bot with Wav2Vec2.0",
60
- description="Speak to the bot and get a response!"
61
  )
62
 
63
  # Launch the interface
64
- iface.launch()
 
15
 
16
  def speech_to_text(audio_file):
17
  """Convert speech in audio file to text using Wav2Vec2"""
18
+ audio_input, _ = librosa.load(audio_file, sr=16000) # Load the audio
19
  input_values = processor(audio_input, return_tensors="pt").input_values
20
 
21
  # Perform speech-to-text
 
53
  # Create Gradio interface for audio input/output
54
  iface = gr.Interface(
55
  fn=process_audio,
56
+ inputs=gr.Audio(source="microphone", type="filepath"), # Corrected for real-time audio input
57
+ outputs=[gr.Textbox(), gr.Audio(type="filepath")], # Corrected for real-time audio output
58
  live=True,
59
  title="Voice Bot with Wav2Vec2.0",
60
+ description="Speak to the bot and get a response instantly! This bot listens and responds like Google Assistant/Siri."
61
  )
62
 
63
  # Launch the interface
64
+ iface.launch(share=True)