rafaa commited on
Commit
adc749b
·
verified ·
1 Parent(s): 1b0aaa8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -2,6 +2,12 @@ from huggingface_hub import InferenceClient
2
  import gradio as gr
3
  from datetime import datetime
4
  import pytz
 
 
 
 
 
 
5
 
6
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
7
 
@@ -106,10 +112,30 @@ def generate(
106
  yield output
107
  return output
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  mychatbot = gr.Chatbot(
110
  avatar_images=["./user.png", "./stella.jpg"], bubble_full_width=False, show_label=False, show_copy_button=True, likeable=True)
111
 
112
  demo = gr.ChatInterface(fn=generate,
 
 
 
 
 
113
  chatbot=mychatbot,
114
  title="Stella 🌸",
115
  retry_btn=None,
 
2
  import gradio as gr
3
  from datetime import datetime
4
  import pytz
5
+ import os
6
+
7
+ elevenlabsKey = os.environ.get("11_READ_TOKEN", None)
8
+ voice = os.environ.get("VOICE_ID", None)
9
+ model = "eleven_multilingual_v2"
10
+ ttsPassword = os.environ.get("TTS_PASSWORD", None)
11
 
12
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
13
 
 
112
  yield output
113
  return output
114
 
115
+
116
+ # Check if the checkbox is selected and the correct password is provided
117
+ if use_checkbox and password == ttsPassword:
118
+ # Generate the audio file
119
+ audio = elevenlabs.generate(output, voice, model, api_key=elevenlabsKey)
120
+
121
+ # Play the audio file
122
+ elevenlabs.play(audio)
123
+
124
+ # Your existing code
125
+
126
+ # Adding a checkbox and password input to the Gradio interface
127
+ checkbox = gr.Checkbox(component=generate, label="Use Text-to-Speech", default=False)
128
+ password_input = gr.Textbox("Password", default=None, password=True, placeholder="Enter password")
129
+
130
  mychatbot = gr.Chatbot(
131
  avatar_images=["./user.png", "./stella.jpg"], bubble_full_width=False, show_label=False, show_copy_button=True, likeable=True)
132
 
133
  demo = gr.ChatInterface(fn=generate,
134
+ inputs=[
135
+ gr.Textbox("User Input", default=None),
136
+ gr.Conditional(password_input, condition=lambda use_checkbox: use_checkbox),
137
+ checkbox
138
+ ],
139
  chatbot=mychatbot,
140
  title="Stella 🌸",
141
  retry_btn=None,