Spaces:
Runtime error
Runtime error
katospiegel
commited on
Commit
•
e9cf21b
1
Parent(s):
b1ed6da
Little function to deal with no scoring
Browse files- helpers.py +9 -1
- transcription.py +2 -2
helpers.py
CHANGED
@@ -123,9 +123,17 @@ def crear_diccionario(json_data):
|
|
123 |
|
124 |
# Iteramos sobre las palabras del segmento
|
125 |
for palabra in palabras:
|
|
|
126 |
# Obtenemos los valores de la palabra
|
127 |
word = palabra['word']
|
128 |
-
score
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
# Agregamos los valores al diccionario
|
131 |
diccionario['start_time'].append(start_time)
|
|
|
123 |
|
124 |
# Iteramos sobre las palabras del segmento
|
125 |
for palabra in palabras:
|
126 |
+
|
127 |
# Obtenemos los valores de la palabra
|
128 |
word = palabra['word']
|
129 |
+
if 'score'not in palabra.keys():
|
130 |
+
print(segmento)
|
131 |
+
print(palabra)
|
132 |
+
# Agregamos el score por defecto
|
133 |
+
palabra['score'] = 0.5
|
134 |
+
else:
|
135 |
+
score = palabra['score']
|
136 |
+
|
137 |
|
138 |
# Agregamos los valores al diccionario
|
139 |
diccionario['start_time'].append(start_time)
|
transcription.py
CHANGED
@@ -46,7 +46,7 @@ def doWhisperX(audio_file, whisper_model="large-v2", language="es"):
|
|
46 |
|
47 |
audio = whisperx.load_audio(audio_file)
|
48 |
result_whisper = model.transcribe(audio, language=language, batch_size=batch_size)
|
49 |
-
print(result_whisper["segments"]) # before alignment
|
50 |
|
51 |
# delete model if low on GPU resources
|
52 |
# import gc; gc.collect(); torch.cuda.empty_cache(); del model
|
@@ -55,7 +55,7 @@ def doWhisperX(audio_file, whisper_model="large-v2", language="es"):
|
|
55 |
model_a, metadata = whisperx.load_align_model(language_code=result_whisper["language"], device=device)
|
56 |
result_aligned = whisperx.align(result_whisper["segments"], model_a, metadata, audio, device, return_char_alignments=False)
|
57 |
|
58 |
-
print(result_aligned) # after alignment
|
59 |
|
60 |
# delete model if low on GPU resources
|
61 |
# import gc; gc.collect(); torch.cuda.empty_cache(); del model_a
|
|
|
46 |
|
47 |
audio = whisperx.load_audio(audio_file)
|
48 |
result_whisper = model.transcribe(audio, language=language, batch_size=batch_size)
|
49 |
+
#print(result_whisper["segments"]) # before alignment
|
50 |
|
51 |
# delete model if low on GPU resources
|
52 |
# import gc; gc.collect(); torch.cuda.empty_cache(); del model
|
|
|
55 |
model_a, metadata = whisperx.load_align_model(language_code=result_whisper["language"], device=device)
|
56 |
result_aligned = whisperx.align(result_whisper["segments"], model_a, metadata, audio, device, return_char_alignments=False)
|
57 |
|
58 |
+
#print(result_aligned) # after alignment
|
59 |
|
60 |
# delete model if low on GPU resources
|
61 |
# import gc; gc.collect(); torch.cuda.empty_cache(); del model_a
|