Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
colorFrom: pink
|
| 5 |
-
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.7.0
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: test
|
| 3 |
+
app_file: app.py
|
|
|
|
|
|
|
| 4 |
sdk: gradio
|
| 5 |
sdk_version: 5.7.0
|
|
|
|
|
|
|
| 6 |
---
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# Backend processing function
|
| 4 |
+
def process_text(input_text):
|
| 5 |
+
# Example processing: Return the text with a prefix
|
| 6 |
+
return f"Processed Text: {input_text}"
|
| 7 |
+
|
| 8 |
+
# Define the Gradio interface
|
| 9 |
+
with gr.Blocks() as demo:
|
| 10 |
+
# Title
|
| 11 |
+
gr.Markdown("# Speech-to-Text Demo with Web Speech API")
|
| 12 |
+
|
| 13 |
+
# Input and output elements
|
| 14 |
+
with gr.Row():
|
| 15 |
+
input_box = gr.Textbox(label="Speech-to-Text Input", elem_id="speech-input")
|
| 16 |
+
output_box = gr.Textbox(label="Processed Output")
|
| 17 |
+
with gr.Row():
|
| 18 |
+
speech_button = gr.Button("Start Speech Recognition", elem_id="speech-button")
|
| 19 |
+
|
| 20 |
+
# Link the input box to the backend processing function
|
| 21 |
+
speech_button.click(process_text, inputs=input_box, outputs=output_box)
|
| 22 |
+
|
| 23 |
+
# Inject JavaScript for Web Speech API
|
| 24 |
+
gr.HTML("""
|
| 25 |
+
<script>
|
| 26 |
+
// Function to initialize and start the Web Speech API
|
| 27 |
+
function startSpeechRecognition() {
|
| 28 |
+
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
| 29 |
+
recognition.lang = 'en-US'; // Set language
|
| 30 |
+
recognition.interimResults = true; // Enable real-time updates
|
| 31 |
+
recognition.continuous = true; // Keep listening for multiple sentences
|
| 32 |
+
|
| 33 |
+
// Handle results
|
| 34 |
+
recognition.onresult = function(event) {
|
| 35 |
+
const transcript = Array.from(event.results)
|
| 36 |
+
.map(result => result[0].transcript)
|
| 37 |
+
.join('');
|
| 38 |
+
document.getElementById("speech-input").value = transcript; // Update the input box
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
// Handle errors
|
| 42 |
+
recognition.onerror = function(event) {
|
| 43 |
+
console.error("Speech Recognition Error:", event.error);
|
| 44 |
+
alert("Speech recognition error: " + event.error);
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
recognition.start(); // Start listening
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
// Attach the start function to the button click
|
| 51 |
+
document.getElementById('speech-button').addEventListener('click', startSpeechRecognition);
|
| 52 |
+
</script>
|
| 53 |
+
""")
|
| 54 |
+
|
| 55 |
+
# Launch the demo
|
| 56 |
+
demo.launch(share=True, port= 20005)
|