Angelo25 commited on
Commit
07d7fb4
·
verified ·
1 Parent(s): 94dff9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -7,6 +7,7 @@ llm_pipe = pipeline(
7
  model="microsoft/Phi-3-mini-4k-instruct",
8
  device_map="auto", # needs `pip install accelerate`; remove to run on CPU only
9
  torch_dtype="auto",
 
10
  )
11
  tts_pipe = pipeline("text-to-speech", model="facebook/mms-tts-eng")
12
 
@@ -22,12 +23,14 @@ def process_audio(audio_path):
22
  {"role": "system", "content": "You are a helpful voice assistant. Answer in 1-3 short sentences."},
23
  {"role": "user", "content": user_text},
24
  ]
25
- reply = llm_pipe(
26
  messages,
27
  max_new_tokens=100,
28
- return_full_text=False,
29
  do_sample=False,
30
- )[0]["generated_text"].strip()
 
 
 
31
 
32
  # 3. Reply -> speech
33
  speech = tts_pipe(reply)
 
7
  model="microsoft/Phi-3-mini-4k-instruct",
8
  device_map="auto", # needs `pip install accelerate`; remove to run on CPU only
9
  torch_dtype="auto",
10
+ trust_remote_code=True, # Phi-3 needs this on some transformers versions
11
  )
12
  tts_pipe = pipeline("text-to-speech", model="facebook/mms-tts-eng")
13
 
 
23
  {"role": "system", "content": "You are a helpful voice assistant. Answer in 1-3 short sentences."},
24
  {"role": "user", "content": user_text},
25
  ]
26
+ output = llm_pipe(
27
  messages,
28
  max_new_tokens=100,
 
29
  do_sample=False,
30
+ )
31
+ # Chat-formatted input returns the full conversation in "generated_text";
32
+ # the assistant's reply is the last message in that list.
33
+ reply = output[0]["generated_text"][-1]["content"].strip()
34
 
35
  # 3. Reply -> speech
36
  speech = tts_pipe(reply)