介绍
感谢所有观看前文的人,感谢喜欢和收藏的人!
没想到一天的浏览量会达到1000,所以我很开心! ?
这篇文章是上一篇的续篇,所以如果你还没有看过,请先看看上一篇!
其他文章
上一篇文章
关于耳语
2022/09/22,OpenAI 公布了语音识别模型 Whisper。 Whisper 是一个具有人类级别的鲁棒性和语音识别准确性的神经网络,它是开源的,所以任何人都可以使用它!
[参考]
官方网站:https://openai.com/blog/whisper
纸:https://cdn.openai.com/papers/whisper.pdf
GitHub:https://github.com/openai/whisper
使用 Gradio 构建应用程序
Gradio 是一个 Python 库,可以轻松地在 Web 应用程序中创建机器学习模型演示。官网有一个机器学习模型的demo,它可以自动识别草图并提出问题,请访问该站点并尝试一下!
官方网站:https://gradio.app/
基本用法
在 Google Colab 上安装 gradio。
!pip install gradio
运行下面的代码。
import gradio as gr
def greet(name):
return "Hello " + name + "!!"
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()
然后演示应用程序启动。您可以在 72 小时内从下面的链接访问它。由于以这种方式生成了公共URL,因此可以向公众开放。
使用 Whisper 和 Gradio 构建语音识别应用程序
让我们使用 Whisper 实际创建一个语音识别应用程序!
首先,我们将为 Whisper 创建一个模型,参考上一篇文章。 (我将运行类型设置为 GPU 并选择 base 作为模型)
import whisper
import gradio as gr
model = whisper.load_model("base")
接下来,定义使用 Gradio 构建的应用程序的主要功能。上次指定音源数据“001.mp3”的存储目的地的地方,输入替换为变量
def speechRecognitionModel(input):
# load audio and pad/trim it to fit 30 seconds
audio = whisper.load_audio(input)
audio = whisper.pad_or_trim(audio)
# make log-Mel spectrogram and move to the same device as the model
mel = whisper.log_mel_spectrogram(audio).to(model.device)
# detect the spoken language
_, probs = model.detect_language(mel)
print(f"Detected language: {max(probs, key=probs.get)}")
# decode the audio
options = whisper.DecodingOptions()
result = whisper.decode(model, mel, options)
# return the recognized text
return result.text
要在 gradle 中启动演示,请运行以下代码。
gr.Interface(
title = 'Whisper Speech Recognition Model',
fn=speechRecognitionModel,
inputs=[
gr.inputs.Audio(source="microphone", type="filepath")
],
outputs=[
"textbox"
],
live=True).launch()
这是运行它的结果。我还粘贴了一个72小时有效的网址,所以请尝试语音识别!
看了天气预报的手稿,试了语音识别
这句话就是这次的挑战。
这是 Whisper 语音识别模型识别的结果。
难以辨认的词是“晴天”和“小心”。我将“名古屋”读作“名巴屋”,可能是因为我的发音错误。
这就是使用 Whisper 和 Gradio 创建语音识别应用程序的全部内容!您可以轻松尝试,所以请尝试自己移动Google Colab!
下一篇文章
原创声明:本文系作者授权爱码网发表,未经许可,不得转载;
原文地址:https://www.likecs.com/show-308626882.html