Spaces:
Sleeping
Sleeping
update the ai use in app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,8 @@ device = "cpu"
|
|
| 11 |
print("Loading Whisper STT Model...")
|
| 12 |
whisper_model = whisper.load_model("small", device=device)
|
| 13 |
|
| 14 |
-
|
|
|
|
| 15 |
print(f"Loading custom NLLB model from {model_path}...")
|
| 16 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 17 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_path).to(device)
|
|
@@ -71,7 +72,6 @@ def universal_translator(text, audio_path, source_lang_name, target_lang_name):
|
|
| 71 |
|
| 72 |
translation = tokenizer.batch_decode(output_tokens, skip_special_tokens=True)[0].strip()
|
| 73 |
|
| 74 |
-
# MODIFICATION: Return both the transcription text and translation text
|
| 75 |
return working_text, translation
|
| 76 |
|
| 77 |
# 3. Gradio Interface Layout
|
|
@@ -88,11 +88,9 @@ with gr.Blocks(theme=gr.themes.Base()) as demo:
|
|
| 88 |
submit_btn = gr.Button("Process Translation", variant="primary")
|
| 89 |
|
| 90 |
with gr.Column():
|
| 91 |
-
# MODIFICATION: Added text block interface container to capture the output transcript
|
| 92 |
transcription_out = gr.Textbox(label="Transcribed/Source Text", lines=3, interactive=False)
|
| 93 |
output_text = gr.Textbox(label="Translation Result", lines=4, interactive=False)
|
| 94 |
|
| 95 |
-
# MODIFICATION: Changed outputs array to map data cleanly to BOTH UI textboxes
|
| 96 |
submit_btn.click(
|
| 97 |
fn=universal_translator,
|
| 98 |
inputs=[text_in, audio_in, src_lang, tgt_lang],
|
|
|
|
| 11 |
print("Loading Whisper STT Model...")
|
| 12 |
whisper_model = whisper.load_model("small", device=device)
|
| 13 |
|
| 14 |
+
# Updated to pull from your new organization model repository
|
| 15 |
+
model_path = "Akariieieie/fine_tuned_dialectgov4" # <-- REPLACE WITH YOUR ORG & MODEL REPO
|
| 16 |
print(f"Loading custom NLLB model from {model_path}...")
|
| 17 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 18 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_path).to(device)
|
|
|
|
| 72 |
|
| 73 |
translation = tokenizer.batch_decode(output_tokens, skip_special_tokens=True)[0].strip()
|
| 74 |
|
|
|
|
| 75 |
return working_text, translation
|
| 76 |
|
| 77 |
# 3. Gradio Interface Layout
|
|
|
|
| 88 |
submit_btn = gr.Button("Process Translation", variant="primary")
|
| 89 |
|
| 90 |
with gr.Column():
|
|
|
|
| 91 |
transcription_out = gr.Textbox(label="Transcribed/Source Text", lines=3, interactive=False)
|
| 92 |
output_text = gr.Textbox(label="Translation Result", lines=4, interactive=False)
|
| 93 |
|
|
|
|
| 94 |
submit_btn.click(
|
| 95 |
fn=universal_translator,
|
| 96 |
inputs=[text_in, audio_in, src_lang, tgt_lang],
|