Siddhant commited on
Commit
03648b3
1 Parent(s): 925a881

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -72,7 +72,7 @@ ASR_model = AutoModelForSpeechSeq2Seq.from_pretrained(
72
  ).to("cpu")
73
  LM_tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM-360M-Instruct")
74
  LM_model = AutoModelForCausalLM.from_pretrained(
75
- "HuggingFaceTB/SmolLM-360M-Instruct", torch_dtype=torch_dtype, trust_remote_code=True
76
  ).to("cpu")
77
  LM_pipe = pipeline(
78
  "text-generation", model=LM_model, tokenizer=LM_tokenizer, device="cpu"
@@ -109,7 +109,7 @@ def transcribe(stream, new_chunk):
109
  duration_ms = len(array) / sr * 1000
110
  if (not(duration_ms < min_speech_ms or duration_ms > max_speech_ms)):
111
  input_features = ASR_processor(
112
- spoken_prompt, sampling_rate=16000, return_tensors="pt"
113
  ).input_features
114
  input_features = input_features.to("cpu", dtype="float16")
115
  pred_ids = ASR_model.generate(input_features, gen_max_new_tokens=128, gen_min_new_tokens=0, gen_num_beams=1, gen_return_timestamps=False,gen_task="transcribe",gen_language="en")
@@ -119,7 +119,7 @@ def transcribe(stream, new_chunk):
119
  # prompt=ASR_model.transcribe(array)["text"].strip()
120
  chat.append({"role": user_role, "content": prompt})
121
  chat_messages = chat.to_list()
122
- output=pipeline(
123
  chat_messages,
124
  gen_max_new_tokens=128,
125
  gen_min_new_tokens=0,
 
72
  ).to("cpu")
73
  LM_tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM-360M-Instruct")
74
  LM_model = AutoModelForCausalLM.from_pretrained(
75
+ "HuggingFaceTB/SmolLM-360M-Instruct", torch_dtype="float16", trust_remote_code=True
76
  ).to("cpu")
77
  LM_pipe = pipeline(
78
  "text-generation", model=LM_model, tokenizer=LM_tokenizer, device="cpu"
 
109
  duration_ms = len(array) / sr * 1000
110
  if (not(duration_ms < min_speech_ms or duration_ms > max_speech_ms)):
111
  input_features = ASR_processor(
112
+ array, sampling_rate=16000, return_tensors="pt"
113
  ).input_features
114
  input_features = input_features.to("cpu", dtype="float16")
115
  pred_ids = ASR_model.generate(input_features, gen_max_new_tokens=128, gen_min_new_tokens=0, gen_num_beams=1, gen_return_timestamps=False,gen_task="transcribe",gen_language="en")
 
119
  # prompt=ASR_model.transcribe(array)["text"].strip()
120
  chat.append({"role": user_role, "content": prompt})
121
  chat_messages = chat.to_list()
122
+ output=LM_pipe(
123
  chat_messages,
124
  gen_max_new_tokens=128,
125
  gen_min_new_tokens=0,