Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix api torchaudio.load bug #75

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import torchaudio
from model import SenseVoiceSmall
from funasr.utils.postprocess_utils import rich_transcription_postprocess
from io import BytesIO


class Language(str, Enum):
auto = "auto"
Expand Down Expand Up @@ -49,9 +51,11 @@ async def turn_audio_to_text(files: Annotated[List[bytes], File(description="wav
audios = []
audio_fs = 0
for file in files:
data_or_path_or_list, audio_fs = torchaudio.load(file)
file_io = BytesIO(file)
godxiaoji marked this conversation as resolved.
Show resolved Hide resolved
data_or_path_or_list, audio_fs = torchaudio.load(file_io)
data_or_path_or_list = data_or_path_or_list.mean(0)
audios.append(data_or_path_or_list)
file_io.close()
if lang == "":
lang = "auto"
if keys == "":
Expand Down