Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -181,12 +181,11 @@ async def transcribe_and_answer(
|
|
181 |
# Load audio using torchaudio
|
182 |
waveform, sample_rate = torchaudio.load(wav_buffer)
|
183 |
|
184 |
-
#
|
185 |
-
|
186 |
-
waveform = waveform.to(torch.float32)
|
187 |
|
188 |
# Step 4: Transcribe the audio
|
189 |
-
transcription_result = nlp_speech_to_text(
|
190 |
transcription_text = transcription_result['text']
|
191 |
|
192 |
# Step 5: Parse the JSON-formatted questions
|
@@ -212,7 +211,6 @@ async def transcribe_and_answer(
|
|
212 |
except Exception as e:
|
213 |
return JSONResponse(content={"error": f"Error processing audio or answering questions: {str(e)}"}, status_code=500)
|
214 |
|
215 |
-
|
216 |
# Set up CORS middleware
|
217 |
origins = ["*"] # or specify your list of allowed origins
|
218 |
app.add_middleware(
|
|
|
181 |
# Load audio using torchaudio
|
182 |
waveform, sample_rate = torchaudio.load(wav_buffer)
|
183 |
|
184 |
+
# Convert waveform to float32 and ensure it's a numpy array
|
185 |
+
waveform_np = waveform.numpy().astype(np.float32)
|
|
|
186 |
|
187 |
# Step 4: Transcribe the audio
|
188 |
+
transcription_result = nlp_speech_to_text(waveform_np)
|
189 |
transcription_text = transcription_result['text']
|
190 |
|
191 |
# Step 5: Parse the JSON-formatted questions
|
|
|
211 |
except Exception as e:
|
212 |
return JSONResponse(content={"error": f"Error processing audio or answering questions: {str(e)}"}, status_code=500)
|
213 |
|
|
|
214 |
# Set up CORS middleware
|
215 |
origins = ["*"] # or specify your list of allowed origins
|
216 |
app.add_middleware(
|