KingNish commited on
Commit
6cd6646
·
verified ·
1 Parent(s): 4713d0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -5,6 +5,7 @@ from transformers import pipeline
5
  import tempfile
6
  import os
7
  import uuid
 
8
 
9
  MODEL_NAME = "ylacombe/whisper-large-v3-turbo"
10
  BATCH_SIZE = 8
@@ -24,9 +25,11 @@ def transcribe(inputs, previous_transcription):
24
  filename = f"{uuid.uuid4().hex}.wav"
25
  filepath = os.path.join(tempfile.gettempdir(), filename)
26
 
 
 
 
27
  # Save the audio data to the temporary file
28
- with open(filepath, "wb") as f:
29
- f.write(inputs[1])
30
 
31
  previous_transcription += pipe(filepath, batch_size=BATCH_SIZE, generate_kwargs={"task": "transcribe"}, return_timestamps=True)["text"]
32
 
 
5
  import tempfile
6
  import os
7
  import uuid
8
+ import scipy.io.wavfile
9
 
10
  MODEL_NAME = "ylacombe/whisper-large-v3-turbo"
11
  BATCH_SIZE = 8
 
25
  filename = f"{uuid.uuid4().hex}.wav"
26
  filepath = os.path.join(tempfile.gettempdir(), filename)
27
 
28
+ # Extract sample rate and audio data from the tuple
29
+ sample_rate, audio_data = inputs
30
+
31
  # Save the audio data to the temporary file
32
+ scipy.io.wavfile.write(filepath, sample_rate, audio_data)
 
33
 
34
  previous_transcription += pipe(filepath, batch_size=BATCH_SIZE, generate_kwargs={"task": "transcribe"}, return_timestamps=True)["text"]
35