broadfield commited on
Commit
933b9d8
·
verified ·
1 Parent(s): 8450371

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -11,6 +11,7 @@ client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
11
  def format_prompt(message, history):
12
  prompt=""
13
  if history:
 
14
  prompt = "<s>"
15
  for user_prompt, bot_response in history:
16
  #print (bot_response)
@@ -47,8 +48,6 @@ def load_mod(model):
47
  pp.load_mod(model)
48
  yield f"Voice Loaded: {model}"
49
  def tts(inp,names,length,noise,width,sen_pause):
50
- print(inp)
51
- print(inp[-1][-1])
52
  yield from pp.stream_tts(inp[-1][-1],names,length,noise,width,sen_pause)
53
  with gr.Blocks() as iface:
54
  aud=gr.Audio(streaming=True, autoplay=True)
@@ -58,10 +57,9 @@ with gr.Blocks() as iface:
58
  submit_b = gr.Button()
59
  stop_b = gr.Button("Stop")
60
  clear = gr.ClearButton([chatbot,prompt,aud])
61
- speak=gr.Button()
62
  with gr.Accordion("Voice Controls",open=False):
63
  msg = gr.HTML("""""")
64
- names=gr.Dropdown(label="Voice", choices=pp.key_list,value="en_US-joe-medium")
65
  length=gr.Slider(label="Length", minimum=0.01, maximum=10.0, value=1)
66
  noise=gr.Slider(label="Noise", minimum=0.01, maximum=3.0, value=0.5)
67
  width=gr.Slider(label="Noise Width", minimum=0.01, maximum=3.0, value=0.5)
@@ -70,8 +68,7 @@ with gr.Blocks() as iface:
70
  with gr.Row(visible=False):
71
  stt=gr.Textbox()
72
  iface.load(load_mod,names,msg)
73
- sub_b = submit_b.click(generate, [prompt,chatbot],[chatbot,stt]).then(tts,[chatbot,names,length,noise,width,sen_pause],aud)
74
- #ub_e = prompt.submit(generate, [prompt, chatbot], [chatbot,stt])
75
  names_change=names.change(load_mod,names,msg)
76
  stop_b.click(None,None,None, cancels=[sub_b,names_change])
77
  iface.queue(default_concurrency_limit=10).launch(max_threads=40)
 
11
  def format_prompt(message, history):
12
  prompt=""
13
  if history:
14
+ print(history)
15
  prompt = "<s>"
16
  for user_prompt, bot_response in history:
17
  #print (bot_response)
 
48
  pp.load_mod(model)
49
  yield f"Voice Loaded: {model}"
50
  def tts(inp,names,length,noise,width,sen_pause):
 
 
51
  yield from pp.stream_tts(inp[-1][-1],names,length,noise,width,sen_pause)
52
  with gr.Blocks() as iface:
53
  aud=gr.Audio(streaming=True, autoplay=True)
 
57
  submit_b = gr.Button()
58
  stop_b = gr.Button("Stop")
59
  clear = gr.ClearButton([chatbot,prompt,aud])
 
60
  with gr.Accordion("Voice Controls",open=False):
61
  msg = gr.HTML("""""")
62
+ names=gr.Dropdown(label="Voice", choices=pp.key_list,value="en_US-ryan-high")
63
  length=gr.Slider(label="Length", minimum=0.01, maximum=10.0, value=1)
64
  noise=gr.Slider(label="Noise", minimum=0.01, maximum=3.0, value=0.5)
65
  width=gr.Slider(label="Noise Width", minimum=0.01, maximum=3.0, value=0.5)
 
68
  with gr.Row(visible=False):
69
  stt=gr.Textbox()
70
  iface.load(load_mod,names,msg)
71
+ sub_b = submit_b.click(generate, [prompt,chatbot],[chatbot]).then(tts,[chatbot,names,length,noise,width,sen_pause],aud)
 
72
  names_change=names.change(load_mod,names,msg)
73
  stop_b.click(None,None,None, cancels=[sub_b,names_change])
74
  iface.queue(default_concurrency_limit=10).launch(max_threads=40)