Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,41 +1,18 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
return "Could not understand audio"
|
| 20 |
-
except sr.RequestError as e:
|
| 21 |
-
return f"Error: {str(e)}"
|
| 22 |
-
|
| 23 |
-
def main():
|
| 24 |
-
st.title("Speech to Text Converter")
|
| 25 |
-
st.write("Upload an audio file and convert it to text.")
|
| 26 |
-
|
| 27 |
-
uploaded_file = st.file_uploader("Choose an audio file", type=["wav", "mp3"])
|
| 28 |
-
|
| 29 |
-
if uploaded_file is not None:
|
| 30 |
-
file_details = {"Filename": uploaded_file.name, "FileType": uploaded_file.type}
|
| 31 |
-
st.write(file_details)
|
| 32 |
-
|
| 33 |
-
if uploaded_file.type == "audio/mp3":
|
| 34 |
-
uploaded_file = convert_audio_to_wav(uploaded_file)
|
| 35 |
-
|
| 36 |
-
text = speech_to_text(uploaded_file)
|
| 37 |
-
st.write("Converted Text:")
|
| 38 |
-
st.write(text)
|
| 39 |
-
|
| 40 |
-
if __name__ == "__main__":
|
| 41 |
-
main()
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import streamlit.components.v1 as components
|
| 3 |
+
|
| 4 |
+
st.chat_input("biggie")
|
| 5 |
+
default_chat_input_value = "Default Value"
|
| 6 |
+
js = f"""
|
| 7 |
+
<script>
|
| 8 |
+
function insertText(dummy_var_to_force_repeat_execution) {{
|
| 9 |
+
var chatInput = parent.document.querySelector('textarea[data-testid="stChatInput"]');
|
| 10 |
+
var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set;
|
| 11 |
+
nativeInputValueSetter.call(chatInput, "{default_chat_input_value}");
|
| 12 |
+
var event = new Event('input', {{ bubbles: true}});
|
| 13 |
+
chatInput.dispatchEvent(event);
|
| 14 |
+
}}
|
| 15 |
+
insertText({len(st.session_state.messages)});
|
| 16 |
+
</script>
|
| 17 |
+
"""
|
| 18 |
+
components(js)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|