I just came across your amazing tool and was looking forward to build a small ASR app with huggingface transformers model. What I need is to enter the path to the mp3 or wav file on the local drive and use it afterwards. However, st.text_input doesn’t seem to work, the model reads only the first character and says the file doesn’t exist.
Here’s my code I need to implement:
from asrecognition import ASREngine
import streamlit as st
st.header("Trascribe your Audio")
filePath = st.text_input(label = "Please enter the path to the file" )
asr = ASREngine("ru", model_path="jonatasgrosman/wav2vec2-large-xlsr-53-russian")
transcriptions = asr.transcribe(filePath)
st.write(result.get("transcription"))
Can you try passing a constant filepath to asr.transcribe()?
Try this:
transcriptions = asr.transcribe('\3.wav')
And then this:
transcriptions = asr.transcribe('\\3.wav')
If the first one fails and the second one works, then the problem is that Python is interpreting the \ as an escape character. So one solution would be to duplicate all \ in your string:
filePath = st.text_input(label = "Please enter the path to the file" )
filePath = filePath.replace('\\', '\\\\')
If both fail, this feels like a bug in asr.transcribe
@thiago, thank you so much for getting back to me, I tried so many ways around this problem, tried to input different paths, but the error came back with the first character only, e.g. ‘[’ or ‘C’ or ‘"’, saying this file does not exist, so I suppose you are right here saying there might be a bug with asrecognition (available at pypi) although it works fine in my pycharm with the following code:
from asrecognition import ASREngine
asr = ASREngine("ru", model_path="jonatasgrosman/wav2vec2-large-xlsr-53-russian")
audio_paths = ["C:/Users/CNata/PycharmProjects/TestASR/3.wav"]
transcriptions = asr.transcribe(audio_paths)
print(transcriptions)
I would appreciate it immensely you looking into it closer. Can it be the case that streamlit separates characters one by one or is it the model after all?
@thiago I apologize for disturbing you, I couldn’t believe the model would refuse to read the path. I used a different approach without a shortcut with asrecognition library and it worked. Thank you for doing such a great job. I really fell in love with your tool. Streamlit is amazing. Keep it up!
Is there any way that I could save the text into a text file?
I am getting several text lines from a user using st.text_area(), and I need to save theem into a text file.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.