fabianzeiher commited on
Commit
8dbb96b
·
1 Parent(s): 45293a9

Force use of swedish

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -1,8 +1,21 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
- pipe_fine = pipeline(model="zeihers-mart/whisper-small-swedish-basic", device_map="auto", model_kwarks={"language":"swedish", "task":"transcribe"})
5
- pipe_raw = pipeline(model="openai/whisper-small", device_map="auto", model_kwarks={"language":"swedish", "task":"transcribe"})
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  def transcribe(audio):
8
  text_sv = pipe_fine(audio)["text"]
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ pipe_fine = pipeline(model="zeihers-mart/whisper-small-swedish-basic", device_map="auto")
5
+ pipe_raw = pipeline(model="openai/whisper-small", device_map="auto")
6
+
7
+ # force swedish
8
+ pipe_fine.model.config.forced_decoder_ids = (
9
+ pipe.tokenizer.get_decoder_prompt_ids(
10
+ language="se", task="transcribe"
11
+ )
12
+ )
13
+
14
+ pipe_raw.model.config.forced_decoder_ids = (
15
+ pipe.tokenizer.get_decoder_prompt_ids(
16
+ language="se", task="transcribe"
17
+ )
18
+ )
19
 
20
  def transcribe(audio):
21
  text_sv = pipe_fine(audio)["text"]