Loren commited on
Commit
934d9ac
·
verified ·
1 Parent(s): 469746c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -22
app.py CHANGED
@@ -7,18 +7,12 @@ MAX_TOKENS = 32000
7
  device = "cuda" if torch.cuda.is_available() else "cpu"
8
  print(f"*** Device: {device}")
9
 
10
- # List models
11
- dict_models = {'Voxtral-Mini-3B-2507': 'mistralai/Voxtral-Mini-3B-2507',
12
- 'Voxtral-Small-24B-2507': 'mistralai/Voxtral-Small-24B-2507'}
13
-
14
- # Load models
15
- list_processor = []
16
- list_model = []
17
- for model_name in dict_models.values():
18
- list_processor.append(AutoProcessor.from_pretrained(model_name))
19
- list_model.append(VoxtralForConditionalGeneration.from_pretrained(model_name,
20
- torch_dtype=torch.bfloat16,
21
- device_map=device))
22
  # Supported languages
23
  dict_languages = {"English": "en",
24
  "French": "fr",
@@ -67,17 +61,12 @@ with gr.Blocks(title="Transcription") as transcript:
67
  with gr.Column():
68
  text_transcript = gr.Textbox(label="Generated Response", lines=10)
69
 
70
- try:
71
- model_index = list(dict_models.keys()).index(sel_model)
72
- submit_transcript.click(
73
- fn=process_transcript,
74
- inputs=[dict_languages[sel_language], list_model[model_index],
75
- list_processor[model_index], sel_audio],
76
- outputs=text_transcript
77
- )
78
- except:
79
- text_transcript = 'Error'
80
 
 
 
 
 
 
81
 
82
  # Launch the app
83
  if __name__ == "__main__":
 
7
  device = "cuda" if torch.cuda.is_available() else "cpu"
8
  print(f"*** Device: {device}")
9
 
10
+ model_name = 'mistralai/Voxtral-Mini-3B-2507'
11
+
12
+ processor = AutoProcessor.from_pretrained(model_name)
13
+ model = VoxtralForConditionalGeneration.from_pretrained(model_name,
14
+ torch_dtype=torch.bfloat16,
15
+ device_map=device)
 
 
 
 
 
 
16
  # Supported languages
17
  dict_languages = {"English": "en",
18
  "French": "fr",
 
61
  with gr.Column():
62
  text_transcript = gr.Textbox(label="Generated Response", lines=10)
63
 
 
 
 
 
 
 
 
 
 
 
64
 
65
+ submit_transcript.click(
66
+ fn=process_transcript,
67
+ inputs=[dict_languages[sel_language], model, processor, sel_audio],
68
+ outputs=text_transcript
69
+ )
70
 
71
  # Launch the app
72
  if __name__ == "__main__":