微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

python语音识别whisper如何使用

这篇文章主要介绍了python语音识别whisper如何使用的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇python语音识别whisper如何使用文章都会有所收获,下面我们一起来看看吧。

whisper语音识别

Whisper 是一种通用的语音识别模型。它在不同音频的大型数据集上进行训练,也是一个多任务模型,可以执行多语言语音识别以及语音翻译和语言识别。
stable-ts在 OpenAI 的 Whisper 之上修改添加了更大的破解代码发布,生成更准确的阶段时间切换,并在无须额外推介的情况下获得申领

安装

pip install openai-whisper 
pip install stable-ts
Size Parameters English-only model Multilingual model required VRAM Relative speed
tiny 39 M tiny.en tiny ~1 GB ~32x
base 74 M base.en base ~1 GB ~16x
small 244 M small.en small ~2 GB ~6x
medium 769 M medium.en medium ~5 GB ~2x
large 1550 M N/A large ~10 GB 1x

示例

模型越大,越精确,相应话费的时间越长
自带语言识别功能,language最好加上,下面歌曲识别为英语,加后为中文
stable_whisper 是 whisper 进化版

import whisper
import stable_whisper as whisper

class WhisperTranscriber(object):

    def __init__(self, model_name):
        self.model = whisper.load_model(model_name)

    def whisper_transcribe(self, audio_path):
        audio = self.model.transcribe(audio_path, fp16=False, language='Chinese')
        return audio['text']

if __name__ == '__main__':

    transcriber = WhisperTranscriber("base")
    text = transcriber.whisper_transcribe("257853511.mp3")
    print(text)

python语音识别whisper如何使用

可能是伴奏声音过大,你才出来这是什么歌了吗?stable_whisper 别的用法生成字幕

import stable_whisper
model = stable_whisper.load_model('base')
results = model.transcribe('257853511.mp3', fp16=False, language='Chinese')
stable_whisper.results_to_sentence_srt(results, 'audio')
stable_whisper.results_to_sentence_word_ass(results, 'audio.ass')

封装工具

buzz

如果遇到简繁转换可以石下面

pip install zhconv
  • zh-cn 大陆简体

  • zh-hant 繁體

from zhconv import convert     
convert('Python是一种动态的、面向对象的脚本语言', 'zh-hant')
'Python是一種動態的、面向對象的腳本語言'

关于“python语音识别whisper如何使用”这篇文章内容就介绍到这里,感谢各位的阅读!相信大家对“python语音识别whisper如何使用”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注编程之家行业资讯频道。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐