Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -69,24 +69,7 @@ body {
|
|
| 69 |
}
|
| 70 |
"""
|
| 71 |
|
| 72 |
-
#
|
| 73 |
-
custom_js = """
|
| 74 |
-
<script>
|
| 75 |
-
function startRecognition() {
|
| 76 |
-
var recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
| 77 |
-
recognition.lang = 'en-US';
|
| 78 |
-
|
| 79 |
-
recognition.onresult = function(event) {
|
| 80 |
-
var speechResult = event.results[0][0].transcript;
|
| 81 |
-
document.getElementById('input_message').value = speechResult;
|
| 82 |
-
};
|
| 83 |
-
|
| 84 |
-
recognition.start();
|
| 85 |
-
}
|
| 86 |
-
</script>
|
| 87 |
-
"""
|
| 88 |
-
|
| 89 |
-
# Create a Gradio chat interface with custom CSS and JS
|
| 90 |
demo = gr.ChatInterface(
|
| 91 |
fn=respond,
|
| 92 |
additional_inputs=[
|
|
@@ -101,15 +84,8 @@ demo = gr.ChatInterface(
|
|
| 101 |
label="Top-p (nucleus sampling)",
|
| 102 |
),
|
| 103 |
],
|
| 104 |
-
css=custom_css
|
| 105 |
-
javascript=custom_js
|
| 106 |
)
|
| 107 |
|
| 108 |
-
# Add a button to start voice recognition
|
| 109 |
-
def add_voice_button():
|
| 110 |
-
return gr.Button("🎤 Speak").onclick(startRecognition)
|
| 111 |
-
|
| 112 |
-
demo.add_component(add_voice_button(), "left", component_id="input_message")
|
| 113 |
-
|
| 114 |
if __name__ == "__main__":
|
| 115 |
demo.launch()
|
|
|
|
| 69 |
}
|
| 70 |
"""
|
| 71 |
|
| 72 |
+
# Create a Gradio chat interface with custom CSS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
demo = gr.ChatInterface(
|
| 74 |
fn=respond,
|
| 75 |
additional_inputs=[
|
|
|
|
| 84 |
label="Top-p (nucleus sampling)",
|
| 85 |
),
|
| 86 |
],
|
| 87 |
+
css=custom_css
|
|
|
|
| 88 |
)
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
if __name__ == "__main__":
|
| 91 |
demo.launch()
|