Spaces:
Runtime error
Runtime error
salmanmapkar
commited on
Commit
•
9764cff
1
Parent(s):
7dc348e
Update app.py
Browse files
app.py
CHANGED
@@ -181,14 +181,14 @@ def Transcribe_V2(num_speakers, speaker_names, audio="temp_audio.wav"):
|
|
181 |
|
182 |
def get_duration(path):
|
183 |
with contextlib.closing(wave.open(path,'r')) as f:
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
|
188 |
def make_embeddings(path, segments, duration):
|
189 |
embeddings = np.zeros(shape=(len(segments), 192))
|
190 |
for i, segment in enumerate(segments):
|
191 |
-
|
192 |
return np.nan_to_num(embeddings)
|
193 |
|
194 |
def segment_embedding(path, segment, duration):
|
@@ -203,7 +203,7 @@ def Transcribe_V2(num_speakers, speaker_names, audio="temp_audio.wav"):
|
|
203 |
clustering = AgglomerativeClustering(num_speakers).fit(embeddings)
|
204 |
labels = clustering.labels_
|
205 |
for i in range(len(segments)):
|
206 |
-
|
207 |
|
208 |
def time(secs):
|
209 |
return datetime.timedelta(seconds=round(secs))
|
|
|
181 |
|
182 |
def get_duration(path):
|
183 |
with contextlib.closing(wave.open(path,'r')) as f:
|
184 |
+
frames = f.getnframes()
|
185 |
+
rate = f.getframerate()
|
186 |
+
return frames / float(rate)
|
187 |
|
188 |
def make_embeddings(path, segments, duration):
|
189 |
embeddings = np.zeros(shape=(len(segments), 192))
|
190 |
for i, segment in enumerate(segments):
|
191 |
+
embeddings[i] = segment_embedding(path, segment, duration)
|
192 |
return np.nan_to_num(embeddings)
|
193 |
|
194 |
def segment_embedding(path, segment, duration):
|
|
|
203 |
clustering = AgglomerativeClustering(num_speakers).fit(embeddings)
|
204 |
labels = clustering.labels_
|
205 |
for i in range(len(segments)):
|
206 |
+
segments[i]["speaker"] = 'SPEAKER ' + str(labels[i] + 1)
|
207 |
|
208 |
def time(secs):
|
209 |
return datetime.timedelta(seconds=round(secs))
|