Marco-Cheung commited on
Commit
de411e0
1 Parent(s): e9f9b4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -15,15 +15,14 @@ device = "cuda:0" if torch.cuda.is_available() else "cpu"
15
 
16
  # load speech translation checkpoint
17
  asr_pipe = pipeline("automatic-speech-recognition", model=ASR_MODEL_NAME, chunk_length_s=10,device=device)
 
 
18
 
19
  # load text-to-speech checkpoint
20
  processor = AutoProcessor.from_pretrained("suno/bark-small")
21
  model = BarkModel.from_pretrained("suno/bark-small").to(device)
22
  sampling_rate = model.generation_config.sample_rate
23
 
24
- # set the forced ids
25
- model.generation_config.forced_decoder_ids = processor.tokenizer.get_decoder_prompt_ids(language='de', task="translate")
26
-
27
  def translate(audio):
28
  outputs = asr_pipe(audio, max_new_tokens=256, generate_kwargs={"task": "translate"})
29
  return outputs["text"]
 
15
 
16
  # load speech translation checkpoint
17
  asr_pipe = pipeline("automatic-speech-recognition", model=ASR_MODEL_NAME, chunk_length_s=10,device=device)
18
+ # set the forced ids
19
+ asr_pipe.model.config.forced_decoder_ids = asr_pipe.tokenizer.get_decoder_prompt_ids(language='de', task="translate")
20
 
21
  # load text-to-speech checkpoint
22
  processor = AutoProcessor.from_pretrained("suno/bark-small")
23
  model = BarkModel.from_pretrained("suno/bark-small").to(device)
24
  sampling_rate = model.generation_config.sample_rate
25
 
 
 
 
26
  def translate(audio):
27
  outputs = asr_pipe(audio, max_new_tokens=256, generate_kwargs={"task": "translate"})
28
  return outputs["text"]