hareballak commited on
Commit
fb4d33c
·
verified ·
1 Parent(s): 26ee315

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -60,10 +60,8 @@ def get_bot_response(query):
60
  # Gradio interface function
61
  def chatbot(audio, message, system_message, max_tokens, temperature, top_p):
62
  if audio is not None:
63
- # Save the audio file temporarily
64
- with open("temp.wav", "wb") as f:
65
- f.write(audio.read())
66
-
67
  # Transcribe the audio using Whisper
68
  transcript = transcribe_audio("temp.wav")
69
  message = transcript # Use the transcript as the input message
@@ -80,7 +78,7 @@ def chatbot(audio, message, system_message, max_tokens, temperature, top_p):
80
  demo = gr.Interface(
81
  fn=chatbot,
82
  inputs=[
83
- gr.Audio(type="numpy", label="Speak to the Bot",recording=True), # Adjusted for microphone input
84
  gr.Textbox(value="How can I help you?", label="Text Input (optional)"),
85
  gr.Textbox(value="You are a friendly chatbot.", label="System message"),
86
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
 
60
  # Gradio interface function
61
  def chatbot(audio, message, system_message, max_tokens, temperature, top_p):
62
  if audio is not None:
63
+ audio_data, sample_rate = audio
64
+ sf.write("temp.wav", audio_data, sample_rate)
 
 
65
  # Transcribe the audio using Whisper
66
  transcript = transcribe_audio("temp.wav")
67
  message = transcript # Use the transcript as the input message
 
78
  demo = gr.Interface(
79
  fn=chatbot,
80
  inputs=[
81
+ gr.Audio(source="microphone",type="numpy", label="Speak to the Bot"), # Adjusted for microphone input
82
  gr.Textbox(value="How can I help you?", label="Text Input (optional)"),
83
  gr.Textbox(value="You are a friendly chatbot.", label="System message"),
84
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),