Spaces:
Build error
Build error
patrickvonplaten
commited on
Commit
•
b393952
1
Parent(s):
8ace0d6
Update app.py
Browse files
app.py
CHANGED
@@ -21,19 +21,23 @@ def transcribe(file_mic, file_upload, target_language):
|
|
21 |
target_code = target_language.split("(")[-1].split(")")[0]
|
22 |
forced_bos_token_id = MAPPING[target_code]
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
30 |
|
31 |
input_values = process_audio_file(file)
|
32 |
|
33 |
sequences = model.generate(input_values, forced_bos_token_id=forced_bos_token_id)
|
34 |
|
35 |
transcription = tokenizer.batch_decode(sequences, skip_special_tokens=True)
|
36 |
-
return transcription[0]
|
37 |
|
38 |
target_language = [
|
39 |
"German (de)",
|
|
|
21 |
target_code = target_language.split("(")[-1].split(")")[0]
|
22 |
forced_bos_token_id = MAPPING[target_code]
|
23 |
|
24 |
+
warn_output = ""
|
25 |
+
if (file_mic is not None) and (file_upload is not None):
|
26 |
+
warn_output = "WARNING: You've uploaded an audio file and used the microphone. The recorded file from the microphone will be used and the uploaded audio will be discarded.\n"
|
27 |
+
file = file_mic
|
28 |
+
elif (file_mic is None) and (file_upload is None):
|
29 |
+
return "ERROR: You have to either use the microphone or upload an audio file"
|
30 |
+
elif file_mic is not None:
|
31 |
+
file = file_mic
|
32 |
+
else:
|
33 |
+
file = file_upload
|
34 |
|
35 |
input_values = process_audio_file(file)
|
36 |
|
37 |
sequences = model.generate(input_values, forced_bos_token_id=forced_bos_token_id)
|
38 |
|
39 |
transcription = tokenizer.batch_decode(sequences, skip_special_tokens=True)
|
40 |
+
return warn_output + transcription[0]
|
41 |
|
42 |
target_language = [
|
43 |
"German (de)",
|