RapidASRDemo / app.py
SWHL's picture
Upload 9 files
e1c3abe
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: liekkaskono@163.com
import streamlit as st
from rapid_paraformer import RapidParaformer
st.set_option("deprecation.showfileUploaderEncoding", False)
config_path = "resources/config.yaml"
paraformer = RapidParaformer(config_path)
if __name__ == "__main__":
st.markdown(
"<h1 style='text-align: center;'><a href='https://github.com/RapidAI/RapidASR' style='text-decoration: none'>RapidASR</a></h1>",
unsafe_allow_html=True,
)
st.markdown(
"""
<p align="left">
<a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Win%2C%20Mac-pink.svg"></a>
<a href=""><img src="https://img.shields.io/badge/Python->=3.6,<3.12-aff.svg"></a>
<a href="https://pepy.tech/project/rapid_paraformer"><img src="https://static.pepy.tech/personalized-badge/rapid_paraformer?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Downloads"></a>
<a href="https://pypi.org/project/rapid_paraformer/"><img alt="PyPI" src="https://img.shields.io/pypi/v/rapid_paraformer"></a>
<a href="https://semver.org/"><img alt="SemVer2.0" src="https://img.shields.io/badge/SemVer-2.0-brightgreen"></a>
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
</p>
""",
unsafe_allow_html=True,
)
video_file = st.file_uploader(label="Upload a file", type=['wav'])
if video_file:
audio_bytes = video_file.read()
st.markdown('#### Raw video:')
save_path = '1.wav'
st.audio(audio_bytes, format='audio/mp3')
with open(save_path, 'wb') as f:
f.write(audio_bytes)
with st.spinner('正在识别中...'):
result = paraformer(save_path)
st.markdown("#### ASR Result:")
st.write(result)