openai开源的whisper在huggingface中使用例子(语音转文字中文)

这篇具有很好参考价值的文章主要介绍了openai开源的whisper在huggingface中使用例子(语音转文字中文)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

openai开源的语音转文字支持多语言在huggingface中使用例子。
目前发现多语言模型large-v2支持中文是繁体,因此需要繁体转简体。
后续编写微调训练例子

GitHub地址:
https://github.com/openai/whisper

!pip install zhconv
!pip install whisper
!pip install tqdm
!pip install ffmpeg-python
!pip install transformers
!pip install librosa

from transformers import WhisperProcessor, WhisperForConditionalGeneration

import librosa
import torch
from zhconv import convert
import warnings

warnings.filterwarnings("ignore")

audio_file = f"test.wav"
#load audio file
audio, sampling_rate = librosa.load(audio_file, sr=16_000)

# # audio
# display.Audio(audio_file, autoplay=True)

# load model and processor
processor = WhisperProcessor.from_pretrained("openai/whisper-large-v2")
model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-large-v2")
tokenizer = WhisperProcessor.from_pretrained("openai/whisper-large-v2")

processor.save_pretrained("openai/model/whisper-large-v2")
model.save_pretrained("openai/model/whisper-large-v2")
tokenizer.save_pretrained("openai/model/whisper-large-v2")

processor = WhisperProcessor.from_pretrained("openai/model/whisper-large-v2")
model = WhisperForConditionalGeneration.from_pretrained("openai/model/whisper-large-v2")
tokenizer = WhisperProcessor.from_pretrained("openai/model/whisper-large-v2")


# load dummy dataset and read soundfiles
# ds = load_dataset("common_voice", "fr", split="test", streaming=True)
# ds = ds.cast_column("audio", datasets.Audio(sampling_rate=16_000))
# input_speech = next(iter(ds))["audio"]["array"]
model.config.forced_decoder_ids = processor.get_decoder_prompt_ids(language="zh", task="transcribe")
input_features = processor(audio, return_tensors="pt").input_features
predicted_ids = model.generate(input_features)
# transcription = processor.batch_decode(predicted_ids)

transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
print(transcription)
print('转化为简体结果:', convert(transcription, 'zh-cn'))
It is strongly recommended to pass the `sampling_rate` argument to this function. Failing to do so can result in silent errors that might be hard to debug.


['启动开始录音']
转化为简体结果: 启动开始录音
input_features = processor(audio, return_tensors="pt").input_features
predicted_ids = model.generate(input_features)
# transcription = processor.batch_decode(predicted_ids)

transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
print(transcription)
print('转化为简体结果:', convert(transcription, 'zh-cn'))
It is strongly recommended to pass the `sampling_rate` argument to this function. Failing to do so can result in silent errors that might be hard to debug.


['启动开始录音']
转化为简体结果: 启动开始录音
#长文本如下
#使用参考网站:https://huggingface.co/openai/whisper-large-v2

openai开源的whisper在huggingface中使用例子(语音转文字中文)文章来源地址https://www.toymoban.com/news/detail-505214.html

到了这里,关于openai开源的whisper在huggingface中使用例子(语音转文字中文)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • OpenAI又一神器!Whisper 语音转文字手把手教程

    语音转文字在许多不同领域都有着广泛的应用。以下是一些例子: 1.字幕制作:语音转文字可以帮助视频制作者快速制作字幕,这在影视行业和网络视频领域非常重要。通过使用语音转文字工具,字幕制作者可以更快地生成字幕,从而缩短制作时间,节省人工成本,并提高制

    2024年02月09日
    浏览(46)
  • OpenAI 开源语音识别 Whisper

            Whisper是一个通用语音识别模型。它是在各种音频的大型数据集上训练的,也是一个多任务模型,可以执行多语言语音识别以及语音翻译和语言识别。                人工智能公司 OpenAI 拥有 GTP-3 语言模型,并为 GitHub Copilot 提供技术支持的 ,宣布开源了

    2024年02月09日
    浏览(51)
  • Whisper OpenAI开源语音识别模型

    Whisper 是一个自动语音识别(ASR,Automatic Speech Recognition)系统,OpenAI 通过从网络上收集了 68 万小时的多语言(98 种语言)和多任务(multitask)监督数据对 Whisper 进行了训练。OpenAI 认为使用这样一个庞大而多样的数据集,可以提高对口音、背景噪音和技术术语的识别能力。除

    2024年02月16日
    浏览(37)
  • 语音识别开源框架 openAI-whisper

    Whisper 是一种通用的语音识别模型。 它是OpenAI于2022年9月份开源的在各种音频的大型数据集上训练的语音识别模型,也是一个可以执行多语言语音识别、语音翻译和语言识别的多任务模型。 GitHub - yeyupiaoling/Whisper-Finetune: 微调Whisper语音识别模型和加速推理,支持Web部署和Andr

    2024年02月17日
    浏览(38)
  • whisper 强大且开源的语音转文字

    说起来语音转换文字,openai旗下的whisper很是好用,推理也很快,同时支持cpu和GPU。 GitHub:GitHub - openai/whisper: Robust Speech Recognition via Large-Scale Weak Supervision 相关的参数和内存使用如下: Size Parameters English-only model Multilingual model Required VRAM Relative speed tiny 39 M tiny.en tiny ~1 GB ~32x

    2024年02月10日
    浏览(27)
  • OpenAI开源!!Whisper语音识别实战!!【环境配置+代码实现】

    目录 环境配置 代码实现 ******  实现 .mp4转换为 .wav文件,识别后进行匹配并输出出现的次数 ******  完整代码实现请私信 安装 ffmpeg 打开网址   https://github.com/BtbN/FFmpeg-Builds/releases 下载如下图所示的文件 下载后解压  我的路径是G:ffmpeg-master-latest-win64-gpl-shared

    2024年02月13日
    浏览(40)
  • 可以白嫖的语音识别开源项目whisper的搭建详细过程 | 如何在Linux中搭建OpenAI开源的语音识别项目Whisper

    原文来自我个人的博客。 服务器为GPU服务器。点击这里跳转到我使用的GPU服务器。我搭建 whisper 选用的是 NVIDIA A 100显卡,4GB显存。 Python版本要在3.8~3.11之间。 输入下面命令查看使用的Python版本。 为啥要安装Anaconda? 为了减少不同项目使用的库的版本冲突,我们可以使用An

    2024年02月09日
    浏览(37)
  • chatGPT的耳朵!OpenAI的开源语音识别AI:Whisper !

    语音识别是通用人工智能的重要一环!可以说是AI的耳朵! 它可以让机器理解人类的语音,并将其转换为文本或其他形式的输出。 语音识别的应用场景非常广泛,比如智能助理、语音搜索、语音翻译、语音输入等等。 然而,语音识别也面临着很多挑战,比如不同的语言、口

    2024年03月14日
    浏览(37)
  • OpenAI开源全新解码器和语音识别模型Whisper-v3

    在11月7日OpenAI的首届开发者大会上,除了推出一系列重磅产品之外,还开源了两款产品,全新解码器Consistency Decoder(一致性解码器)和最新语音识别模型Whisper v3。 据悉,Consistency Decoder可以替代Stable Diffusion VAE解码器。该解码器可以改善所有与Stable Diffusion 1.0+ VAE兼容的图像,

    2024年02月05日
    浏览(36)
  • OpenAI开源语音识别模型Whisper在Windows系统的安装详细过程

    Python的安装很简单,点击这里进行下载。 安装完成之后,输入python -V可以看到版本信息,说明已经安装成功了。 如果输入python -V命令没有看到上面的这样的信息,要么是安装失败,要么是安装好之后没有自动配置环境变量,如何配置环境变量可以从网上搜索。 Python的具体安

    2024年02月08日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包