Spaces:
Runtime error
Runtime error
File size: 1,088 Bytes
1ffd672 f8d0565 0c3b1db f8d0565 0c3b1db f8d0565 0c3b1db f8d0565 1ffd672 f8d0565 0c3b1db f8d0565 1ffd672 f6906f4 6a5f5ff f8d0565 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
import streamlit as st
import langcodes
from allosaurus.app import read_recognizer
def get_langcode_for_allosaurus(input_code):
langcode = "ipa" # the default allosaurus recognizer
description = "the default universal setting, not specific to any language"
try:
lang = langcodes.get(input_code)
langcode = lang.to_alpha3()
description = lang.display_name()
except langcodes.LanguageTagError as e:
pass
return langcode, description
if __name__ == "__main__":
input_code = st.text_input("(optional) 2 or 3-letter ISO code for input language", max_chars=3)
langcode, description = get_langcode_for_allosaurus(input_code)
st.write(f"Instructing Allosaurus to recognize using language {langcode}. That is, {}")
model = read_recognizer()
uploaded_file = st.file_uploader("Choose a file")
if uploaded_file is not None:
audio_bytes = uploaded_file.getvalue()
# audio_bytes = audio_file.read()
st.audio(audio_bytes, format='audio/wav')
result = model.recognize(audio_bytes, langcode)
st.write(result)
|