Whisper 语音识别模型 您所在的位置:网站首页 tiny英语怎么读语音 Whisper 语音识别模型

Whisper 语音识别模型

2023-06-11 02:57| 来源: 网络整理| 查看: 265

Whisper 语音识别模型

Whisper 是一种通用的语音识别模型。它是在包含各种音频的大型数据集上训练的,也是一个可以执行多语言语音识别、语音翻译和语言识别的多任务模型。

开源项目地址:https://github.com/openai/whisper

Whisper 语音识别模型 Transformer 序列到序列模型针对各种语音处理任务进行训练,包括多语言语音识别、语音翻译、口语识别和语音活动检测。这些任务共同表示为由解码器预测的一系列标记,允许单个模型取代传统语音处理管道的多个阶段。多任务训练格式使用一组特殊标记作为任务说明符或分类目标。

设置 我们使用 Python 3.9.9 和PyTorch 1.10.1 来训练和测试我们的模型,但代码库预计将与 Python 3.8-3.11 和最新的 PyTorch 版本兼容。该代码库还依赖于一些 Python 包,最著名的是OpenAI 的 tiktoken,用于实现快速分词器。您可以使用以下命令下载并安装(或更新到)最新版本的 Whisper:

pip install -U openai-whisper

或者,以下命令将从该存储库中拉取并安装最新的提交及其 Python 依赖项:

pip install git+https://github.com/openai/whisper.git

要将软件包更新到此存储库的最新版本,请运行:

pip install --upgrade --no-deps --force-reinstall git+https://github.com/openai/whisper.git

ffmpeg它还需要在您的系统上安装命令行工具,大多数包管理器都提供该工具:

on Ubuntu or Debiansudo apt update && sudo apt install ffmpeg# on Arch Linuxsudo pacman -S ffmpeg# on MacOS using Homebrew (https://brew.sh/)brew install ffmpeg# on Windows using Chocolatey (https://chocolatey.org/)choco install ffmpeg# on Windows using Scoop (https://scoop.sh/)scoop install ffmpeg

您可能rust还需要安装,以防tiktoken不为您的平台提供预构建的轮子。如果您在上述命令中看到安装错误pip install,请按照入门页面安装 Rust 开发环境。此外,您可能需要配置PATH环境变量,例如export PATH=“ H O M E / . c a r g o / b i n : HOME/.cargo/bin: HOME/.cargo/bin:PATH”. 如果安装失败No module named ‘setuptools_rust’,则需要安装setuptools_rust,例如通过运行:

pip install setuptools-rust

可用型号和语言 .en仅英语应用程序的模型往往表现更好,尤其是对于和tiny.en模型base.en。small.en我们观察到,对于和模型,差异变得不那么显着medium.en。

Whisper 的性能因语言而异。下图显示了使用该模型的 Fleurs 数据集按语言的 WER(单词错误率)细分large-v2(数字越小,性能越好)。与其他模型和数据集相对应的其他 WER 分数可以在附录 D.1、D.2 和 D.4 中找到。同时,更多的 BLEU(双语评估替补)分数可以在附录 D.3 中找到。两者都在论文中找到。

命令行用法 以下命令将使用medium模型转录音频文件中的语音:

whisper audio.flac audio.mp3 audio.wav --model medium

默认设置(选择模型small)适用于转录英语。要转录包含非英语语音的音频文件,您可以使用以下选项指定语言–language:

whisper japanese.wav --language Japanese

添加–task translate会将语音翻译成英文:

whisper japanese.wav --language Japanese --task translate

运行以下命令以查看所有可用选项:

whisper --help

有关所有可用语言的列表,请参见tokenizer.py 。

Python 用法 转录也可以在 Python 中执行:

import whispermodel = whisper.load_model(“base”)result = model.transcribe(“audio.mp3”)print(result[“text”])

在内部,该transcribe()方法读取整个文件并使用滑动的 30 秒窗口处理音频,对每个窗口执行自回归序列到序列预测。

whisper.detect_language()下面是和的示例用法whisper.decode(),它提供对模型的较低级别访问。

import whispermodel = whisper.load_model(“base”)# load audio and pad/trim it to fit 30 secondsaudio = whisper.load_audio(“audio.mp3”)audio = whisper.pad_or_trim(audio)# make log-Mel spectrogram and move to the same device as the modelmel = 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 audiooptions = whisper.DecodingOptions()result = whisper.decode(model, mel, options)# print the recognized textprint(result.text)



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有