PhilSpiel commited on
Commit
2bafe3d
·
1 Parent(s): 0d9e816

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -49,26 +49,23 @@ def generate_speech(name, input_text):
49
  for i, msg in enumerate(history_openai_format):
50
  if msg['role'] != 'system':
51
  if msg['role'] == 'user':
52
- transcript += f"{msg['role']}: {input_text}\n\n"
53
  else:
54
- transcript += f"{msg['role']}: {msg['content']}\n\n\n"
55
 
56
  # Return the binary audio data and the transcript
57
  return response.content, transcript
58
 
59
  # Define the Gradio interface with inputs for name and user text
60
- with gr.Interface(
61
  fn=generate_speech,
62
  inputs=[
63
  gr.Textbox(label="Your Name (required):", placeholder="Enter your FIRST NAME"),
64
  gr.Textbox(label="Your question or comment for Johnny:")
65
  ],
 
66
  live=False
67
- ) as iface:
68
- with gr.Tab("Audio"):
69
- iface.outputs.append(gr.Audio(autoplay=True))
70
- with gr.Tab("Transcript"):
71
- iface.outputs.append(gr.TextArea())
72
 
73
  # Launch the interface
74
  iface.launch(show_api=True)
 
49
  for i, msg in enumerate(history_openai_format):
50
  if msg['role'] != 'system':
51
  if msg['role'] == 'user':
52
+ transcript += f"Guest: {input_text}\n\n" # Change 'User' to 'Guest'
53
  else:
54
+ transcript += f"Johnny: {msg['content']}\n\n\n" # Change 'Assistant' to 'Johnny'
55
 
56
  # Return the binary audio data and the transcript
57
  return response.content, transcript
58
 
59
  # Define the Gradio interface with inputs for name and user text
60
+ iface = gr.Interface(
61
  fn=generate_speech,
62
  inputs=[
63
  gr.Textbox(label="Your Name (required):", placeholder="Enter your FIRST NAME"),
64
  gr.Textbox(label="Your question or comment for Johnny:")
65
  ],
66
+ outputs=[gr.Audio(autoplay=True), gr.TextArea(label="Transcript")],
67
  live=False
68
+ )
 
 
 
 
69
 
70
  # Launch the interface
71
  iface.launch(show_api=True)