Commit
·
9da3b59
1
Parent(s):
196d65f
Small style fixs
Browse files
app.py
CHANGED
|
@@ -61,13 +61,17 @@ def run(input_file, language, history):
|
|
| 61 |
history.append({
|
| 62 |
"error_message": f"Failed to find a model for {language} language :("
|
| 63 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
else:
|
| 65 |
model_instance = CACHED_MODELS_BY_ID.get(model["model_id"], None)
|
| 66 |
if model_instance is None:
|
| 67 |
model_instance = vosk.Model(model_name=model["model_id"])
|
| 68 |
CACHED_MODELS_BY_ID[model["model_id"]] = model_instance
|
| 69 |
|
| 70 |
-
transcription = asr(model_instance, input_file
|
| 71 |
|
| 72 |
logger.info(f"Transcription for {input_file}: {transcription}")
|
| 73 |
|
|
@@ -94,7 +98,7 @@ def run(input_file, language, history):
|
|
| 94 |
gr.Interface(
|
| 95 |
run,
|
| 96 |
inputs=[
|
| 97 |
-
gr.inputs.Audio(source="microphone", type="
|
| 98 |
gr.inputs.Radio(label="Language", choices=LANGUAGES),
|
| 99 |
"state"
|
| 100 |
],
|
|
@@ -110,7 +114,6 @@ gr.Interface(
|
|
| 110 |
.result_item_success {background-color:mediumaquamarine;color:white;align-self:start}
|
| 111 |
.result_item_error {background-color:#ff7070;color:white;align-self:start}
|
| 112 |
""",
|
| 113 |
-
allow_screenshot=False,
|
| 114 |
allow_flagging="never",
|
| 115 |
theme="grass"
|
| 116 |
).launch(enable_queue=True)
|
|
|
|
| 61 |
history.append({
|
| 62 |
"error_message": f"Failed to find a model for {language} language :("
|
| 63 |
})
|
| 64 |
+
elif input_file is None:
|
| 65 |
+
history.append({
|
| 66 |
+
"error_message": f"Record input audio first"
|
| 67 |
+
})
|
| 68 |
else:
|
| 69 |
model_instance = CACHED_MODELS_BY_ID.get(model["model_id"], None)
|
| 70 |
if model_instance is None:
|
| 71 |
model_instance = vosk.Model(model_name=model["model_id"])
|
| 72 |
CACHED_MODELS_BY_ID[model["model_id"]] = model_instance
|
| 73 |
|
| 74 |
+
transcription = asr(model_instance, input_file)
|
| 75 |
|
| 76 |
logger.info(f"Transcription for {input_file}: {transcription}")
|
| 77 |
|
|
|
|
| 98 |
gr.Interface(
|
| 99 |
run,
|
| 100 |
inputs=[
|
| 101 |
+
gr.inputs.Audio(source="microphone", type="filepath", label="Record something..."),
|
| 102 |
gr.inputs.Radio(label="Language", choices=LANGUAGES),
|
| 103 |
"state"
|
| 104 |
],
|
|
|
|
| 114 |
.result_item_success {background-color:mediumaquamarine;color:white;align-self:start}
|
| 115 |
.result_item_error {background-color:#ff7070;color:white;align-self:start}
|
| 116 |
""",
|
|
|
|
| 117 |
allow_flagging="never",
|
| 118 |
theme="grass"
|
| 119 |
).launch(enable_queue=True)
|