首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何提取和存储自动语音识别深度学习应用程序生成的文本?

如何提取和存储自动语音识别深度学习应用程序生成的文本?
EN

Stack Overflow用户
提问于 2022-03-22 07:13:53
回答 1查看 224关注 0票数 1

该应用程序可以在拥抱脸https://huggingface.co/spaces/rowel/asr中查看。

代码语言:javascript
复制
import gradio as gr
from transformers import pipeline


model = pipeline(task="automatic-speech-recognition",
                 model="facebook/s2t-medium-librispeech-asr")
gr.Interface.from_pipeline(model,
                           title="Automatic Speech Recognition (ASR)",
                           description="Using pipeline with Facebook S2T for ASR.",
                           examples=['data/ljspeech.wav',]
                           ).launch()

我不知道文本文件是用那几行代码存储在哪里的。我想把句子文本存储在一个字符串中。

老实说,我只知道基本的python编程。我只想将它们存储到字符串变量中,并对它们执行一些操作。

EN

回答 1

Stack Overflow用户

发布于 2022-05-03 05:36:32

您可以打开Interface.from_pipeline抽象,并定义自己的G电波接口。您需要定义自己的输入、输出和预测函数,从而访问模型中的文本预测。下面是一个例子。

你可以在这里测试https://huggingface.co/spaces/radames/Speech-Recognition-Example

代码语言:javascript
复制
import gradio as gr
from transformers import pipeline


model = pipeline(task="automatic-speech-recognition",
                 model="facebook/s2t-medium-librispeech-asr")


def predict_speech_to_text(audio):
    prediction = model(audio)
    # text variable contains your voice-to-text string
    text = prediction['text']
    return text


gr.Interface(fn=predict_speech_to_text,
             title="Automatic Speech Recognition (ASR)",
             inputs=gr.inputs.Audio(
                 source="microphone", type="filepath", label="Input"),
             outputs=gr.outputs.Textbox(label="Output"),
             description="Using pipeline with F acebook S2T for ASR.",
             examples=['ljspeech.wav'],
             allow_flagging='never'
             ).launch()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71568142

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档