Nafiul Huda commited on
Commit
4bccb09
·
verified ·
1 Parent(s): 3d26a63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -19,7 +19,7 @@ except ImportError:
19
  return func
20
 
21
  # Constants
22
- MODEL_NAME = "Qwen/Qwen2.5-0.5B-Instruct"
23
  VOICE = "zh-CN-XiaoyiNeural"
24
  VRM_MODEL_PATH = "model/Ani.vrm"
25
  ANIMATION_ZIP_PATH = "animation/all_vrma.zip"
@@ -99,7 +99,7 @@ async def generate_speech(text, rate, pitch):
99
  return filename
100
 
101
  @spaces.GPU
102
- def chat_func(user_input, history):
103
  if not user_input:
104
  return "", history, None, {}
105
 
@@ -111,6 +111,8 @@ def chat_func(user_input, history):
111
  messages.append({"role": "user", "content": user_input})
112
 
113
  prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
 
 
114
  outputs = llm_pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.75)
115
  response_text = outputs[0]["generated_text"][len(prompt):].strip()
116
 
@@ -136,7 +138,7 @@ def chat_func(user_input, history):
136
  }
137
 
138
  # Generate TTS
139
- audio_path = asyncio.run(generate_speech(data.get("text", ""), data.get("rate", "+0%"), data.get("pitch", "+0Hz")))
140
 
141
  # Update history
142
  history.append((user_input, data.get("text", "")))
@@ -405,7 +407,7 @@ async () => {
405
  }
406
  """
407
 
408
- with gr.Blocks(css=CSS, head=HTML_HEAD) as demo:
409
  history = gr.State([])
410
 
411
  with gr.Group(elem_id="custom-viewport"):
@@ -453,4 +455,4 @@ with gr.Blocks(css=CSS, head=HTML_HEAD) as demo:
453
  demo.load(None, js=JS_CODE)
454
 
455
  if __name__ == "__main__":
456
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
19
  return func
20
 
21
  # Constants
22
+ MODEL_NAME = "Qwen/Qwen2.5-3B-Instruct"
23
  VOICE = "zh-CN-XiaoyiNeural"
24
  VRM_MODEL_PATH = "model/Ani.vrm"
25
  ANIMATION_ZIP_PATH = "animation/all_vrma.zip"
 
99
  return filename
100
 
101
  @spaces.GPU
102
+ async def chat_func(user_input, history):
103
  if not user_input:
104
  return "", history, None, {}
105
 
 
111
  messages.append({"role": "user", "content": user_input})
112
 
113
  prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
114
+
115
+ # Run pipeline
116
  outputs = llm_pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.75)
117
  response_text = outputs[0]["generated_text"][len(prompt):].strip()
118
 
 
138
  }
139
 
140
  # Generate TTS
141
+ audio_path = await generate_speech(data.get("text", ""), data.get("rate", "+0%"), data.get("pitch", "+0Hz"))
142
 
143
  # Update history
144
  history.append((user_input, data.get("text", "")))
 
407
  }
408
  """
409
 
410
+ with gr.Blocks() as demo:
411
  history = gr.State([])
412
 
413
  with gr.Group(elem_id="custom-viewport"):
 
455
  demo.load(None, js=JS_CODE)
456
 
457
  if __name__ == "__main__":
458
+ demo.launch(server_name="0.0.0.0", server_port=7860, css=CSS, head=HTML_HEAD)