Pijush2023 commited on
Commit
26117f7
·
verified ·
1 Parent(s): 7827ab9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -127,7 +127,6 @@ pipe_asr = pipeline(
127
  return_timestamps=True
128
  )
129
 
130
- # Function to handle audio input, transcribe, fetch from Neo4j, and generate audio response
131
  # Function to handle audio input, transcribe, fetch from Neo4j, and generate audio response
132
  def transcribe_and_respond(audio):
133
  if audio is None:
@@ -144,11 +143,8 @@ def transcribe_and_respond(audio):
144
  y = torchaudio.functional.resample(torch.tensor(y), orig_freq=sr, new_freq=target_sr).numpy()
145
  sr = target_sr
146
 
147
- # Prepare input_features for Whisper model
148
- input_features = processor(y, sampling_rate=sr, return_tensors="pt").input_features
149
-
150
  # Transcribe the audio using Whisper with English language setting
151
- result = pipe_asr({"input_features": input_features, "language": "en"}, return_timestamps=False)
152
  question = result.get("text", "")
153
 
154
  # Log the transcribed text for debugging
@@ -169,6 +165,7 @@ def transcribe_and_respond(audio):
169
 
170
  return audio_path, response_text
171
 
 
172
  # Function to clear the transcription state
173
  def clear_transcription_state():
174
  return None, None
 
127
  return_timestamps=True
128
  )
129
 
 
130
  # Function to handle audio input, transcribe, fetch from Neo4j, and generate audio response
131
  def transcribe_and_respond(audio):
132
  if audio is None:
 
143
  y = torchaudio.functional.resample(torch.tensor(y), orig_freq=sr, new_freq=target_sr).numpy()
144
  sr = target_sr
145
 
 
 
 
146
  # Transcribe the audio using Whisper with English language setting
147
+ result = pipe_asr({"raw": y, "sampling_rate": sr}, return_timestamps=False)
148
  question = result.get("text", "")
149
 
150
  # Log the transcribed text for debugging
 
165
 
166
  return audio_path, response_text
167
 
168
+
169
  # Function to clear the transcription state
170
  def clear_transcription_state():
171
  return None, None