Delik commited on
Commit
a68a1ac
·
verified ·
1 Parent(s): 18be947

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -6,6 +6,7 @@ import wavio
6
  from pyannote.audio import Pipeline
7
  from pyannote.audio import Audio
8
  from pyannote.core import Segment
 
9
 
10
  pipeline = Pipeline.from_pretrained(
11
  "pyannote/speaker-diarization-3.1",
@@ -15,9 +16,11 @@ def process_audio(audio):
15
  # Extract the audio data and sample rate from the tuple
16
  audio_data, sample_rate = audio
17
 
 
 
 
18
  # Save the uploaded audio file to a temporary location
19
- with wavio.open("temp.wav", "w", rate=sample_rate, channels=1, sampwidth=2) as wav:
20
- wav.write(audio_data)
21
 
22
  # Use the diarization pipeline to process the audio
23
  diarization = pipeline("temp.wav")
 
6
  from pyannote.audio import Pipeline
7
  from pyannote.audio import Audio
8
  from pyannote.core import Segment
9
+ import numpy as np
10
 
11
  pipeline = Pipeline.from_pretrained(
12
  "pyannote/speaker-diarization-3.1",
 
16
  # Extract the audio data and sample rate from the tuple
17
  audio_data, sample_rate = audio
18
 
19
+ # Ensure the audio data is in the correct format
20
+ audio_data = np.int16(audio_data / np.max(np.abs(audio_data)) * 32767)
21
+
22
  # Save the uploaded audio file to a temporary location
23
+ wavio.write("temp.wav", audio_data, sample_rate, sampwidth=2)
 
24
 
25
  # Use the diarization pipeline to process the audio
26
  diarization = pipeline("temp.wav")