asr 语音识别方法 基于paddle的方法

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2023/3/17 16:25
# @Author : sparkle_code_guy
'''
conda create -n paddlespeech python=3.7 cudnn=7.6.5 cudatoolkit=10.1.243 ffmpeg x264
pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
pip install paddlespeech -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install gradio
'''
import paddle
import gradio as gr
from paddlespeech.cli.asr import ASRExecutor

asr_executor = ASRExecutor()

def recognize_txt(audio_input,record_input):

    if audio_input:
        audio_message = audio_input
    else:
        audio_message = record_input
    text = asr_executor(
        audio_file=audio_message,
        model='conformer_wenetspeech',
        lang='zh',
        sample_rate=16000,
        config=None,  # Set `config` and `ckpt_path` to None to use pretrained model.
        ckpt_path=None,

        force_yes=False,
        device=paddle.get_device())
    return text

audio_input = gr.components.Audio(label='upload',source="upload",type='filepath')
record_input = gr.components.Audio(label='record',source="microphone",type='filepath')
iface = gr.Interface(fn=recognize_txt, inputs=[audio_input,record_input], outputs="text")
iface.launch(share=False,server_name='0.0.0.0',server_port=30001)

源代码直通车参考:paddlespeech 功能测试: 逐步体验paddlespeech包的各个语音功能 (gitee.com)

遗留问题:

目前还未找到办法可以直接传入对应的流式数据或者narray,有想法的可以交流沟通

若使用gpu环境,效率提升特别明显,对gpu的使用需求也仅仅2.5G的显存空间

关于paddlegpu环境的配置参考:(3条消息) 使用anaconda 安装paddle gpu环境_会发paper的学渣的博客-优快云博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

会发paper的学渣

您的鼓励和将是我前进的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值