susnato commited on
Commit
4bbe06f
1 Parent(s): 23e4b7c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -20,7 +20,7 @@ martian_mt_tokenizer = MarianTokenizer.from_pretrained("AbhirupGhosh/opus-mt-fin
20
 
21
  def translate_english_to_hindi(english_text):
22
  tokenized_text = martian_mt_tokenizer.encode(english_text, return_tensors="pt")
23
- generated_token_ids = martian_mt_model.generate(tokenized_text, use_cache=True)
24
  hindi_text = martian_mt_tokenizer.decode(generated_token_ids.numpy()[0])
25
  hindi_text = hindi_text.replace("</s>", "")
26
  hindi_text = hindi_text.replace("<pad>", "")
@@ -29,12 +29,12 @@ def translate_english_to_hindi(english_text):
29
 
30
 
31
  def translate_to_english(audio):
32
- outputs = asr_pipe(audio, generate_kwargs={"task": "transcribe", "use_cache":"True"})
33
  return outputs["text"]
34
 
35
  def synthesise(text):
36
  inputs = processor(text=text, return_tensors="pt").to(device)
37
- speech_values = model.generate(**inputs, use_cache=True)
38
  speech_values = speech_values.cpu().numpy()
39
 
40
  return speech_values
 
20
 
21
  def translate_english_to_hindi(english_text):
22
  tokenized_text = martian_mt_tokenizer.encode(english_text, return_tensors="pt")
23
+ generated_token_ids = martian_mt_model.generate(tokenized_text, use_cache=True, max_new_tokens=128)
24
  hindi_text = martian_mt_tokenizer.decode(generated_token_ids.numpy()[0])
25
  hindi_text = hindi_text.replace("</s>", "")
26
  hindi_text = hindi_text.replace("<pad>", "")
 
29
 
30
 
31
  def translate_to_english(audio):
32
+ outputs = asr_pipe(audio, generate_kwargs={"task": "transcribe", "use_cache":"True", "max_new_tokens":"128"})
33
  return outputs["text"]
34
 
35
  def synthesise(text):
36
  inputs = processor(text=text, return_tensors="pt").to(device)
37
+ speech_values = model.generate(**inputs, use_cache=True, max_new_tokens=128)
38
  speech_values = speech_values.cpu().numpy()
39
 
40
  return speech_values