最近发现有声读物能极大促进我的睡眠,但每个前面都有一段开场语,想把它剪掉,但是有多个开场语,所以就要用到语音识别判断一下再剪。

前两年在本地搭建过识别的环境,奈何识别准确率不行,只能找找API了,后面有时间再弄本地的吧。下面是几个大厂提供的服务,就我个人使用来看,讯飞 > Google > IBM,

但在中文识别准确度上,讯飞是最强的。

Oracle:

被它的Always Free计划吸了一波粉,但是提供的转写服务不支持中文,pass

IBM

优点:有一定的持续免费额度

缺点:准确度不够,官网访问有点慢

乱写的示例:

#coding:utf-8
'''
@version: python3.8
@author: ‘eric‘
@license: Apache Licence
@contact: steinven@qq.com
@software: PyCharm
@file: ibm.py
@time: 2021/6/16 23:05
'''
from __future__ import print_function import traceback apikey = ''
url = '' from watson_developer_cloud import SpeechToTextV1
service = SpeechToTextV1(
iam_apikey=apikey,
url=url) import os, re #总资源文件目录
base_dir = r'36041981' #子目录,存放已被裁剪好的长度为5s的x2m后缀文件(安卓端,喜马拉雅缓存文件),我估计其实就是常用的音频格式,就改了个后缀名
cliped_dir =os.listdir(os.path.join(base_dir,'clip'))
for each in cliped_dir:
try:
filename = re.findall(r"(.*?)\.x2m", each) # 取出.mp3后缀的文件名
if filename:
filename[0] += '.x2m'
with open(os.path.join(base_dir, 'clip', filename[0]),
'rb') as audio_file:
recognize_result = service.recognize(
audio=audio_file,
content_type='audio/mp3',
timestamps=False,
#中文模型,CN_BroadbandModel更准确一点
model='zh-CN_NarrowbandModel',
# model='zh-CN_BroadbandModel', #这两个参数应该是让识别出来的文字更接近于提供的,但实际测试,并没什么用,不知道什么原因
# keywords=list(set([x for x in '曲曲于山川历史为解之谜拓展人生的长度广度人生的长度广度和深度由喜马拉雅联合大理石独家推出探秘类大家好欢迎大家订阅历史未解之谜全记录'])),
#keywords_threshold=0.1,
word_confidence=True).get_result()
if len(recognize_result['results'])==0:
with open('result-1.txt', 'a', encoding='utf-8') as f:
f.write('%s-%s\n' % (filename[0], '-'))
continue
final_result = recognize_result['results'][0]['alternatives'][0]['transcript'].replace(' ', '')
with open('result-1.txt', 'a',encoding='utf-8') as f:
f.write('%s-%s\n' % (filename[0], final_result))
except:
traceback.print_exc()
print(each)

Google

优点:识别速度快

缺点:要挂代__理访问,需付费

文档:快速入门:使用客户端库,本地音频文件的话,不要用文档中的代码,可参考我下面的

乱写的示例:

# coding:utf-8
from os import path AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "268675557.mp3") def transcribe_file(speech_file):
"""Transcribe the given audio file."""
from google.cloud import speech
import io client = speech.SpeechClient() with io.open(speech_file, "rb") as audio_file:
content = audio_file.read() audio = speech.RecognitionAudio(content=content)
config = speech.RecognitionConfig(
encoding=speech.RecognitionConfig.AudioEncoding.ENCODING_UNSPECIFIED,
sample_rate_hertz=16000,
language_code="zh-CN",
) response = client.recognize(config=config, audio=audio) # Each result is for a consecutive portion of the audio. Iterate through
# them to get the transcripts for the entire audio file.
for result in response.results:
# The first alternative is the most likely one for this portion.
print(u"Transcript: {}".format(result.alternatives[0].transcript)) if __name__ == '__main__':
transcribe_file(AUDIO_FILE)

讯飞

优点:有限期的免费额度,识别速度快,中文识别最为准确,国内厂商,开发者上手很容易

缺点:识别速度慢,收费,还挺贵

代码就不贴了,官网很容易找到demo

各大厂的语音识别Speech To Text API使用体验的更多相关文章

  1. 利用Google Speech API实现Speech To Text

    很久很久以前, 网上流传着一个免费的,识别率暴高的,稳定的 Speech To Text API, 那就是Google Speech API. 但是最近再使用的时候,总是返回500 Error. 后来 ...

  2. Speech to Text for iOS

    找了一下 speech to text 可以用的 SDK for iOS 以下幾種方案: NDEV Mobile (有免費方案,不過似乎不支援離線,客戶清單中有 wallmart,支援不少語言) iS ...

  3. Csharp: speech to text, text to speech in win

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  4. mysql connector c++ 1.1 API初步体验

    mysql connector c++ 1.1 API初步体验 1,常用的头文件 #include <mysql_connection.h> #include <mysql_driv ...

  5. 一次神奇的Azure speech to text rest api之旅

    错误Max retries exceeded with url: requests.exceptions.ConnectionError: HTTPSConnectionPool(host='%20e ...

  6. Python 百度语音识别与合成REST API及ffmpeg使用

    操作系统:Windows Python:3.5 欢迎加入学习交流QQ群:657341423 百度语音识别官方文档 百度语音合成官方文档 注意事项:接口支持 POST 和 GET两种方式,个人支持用po ...

  7. <交流贴>android语音识别之科大讯飞语音API的使用

      因为最近在研究语音识别,所以借鉴了一下CreAmazing网友的帖子 Android系统本身其实提供有语音识别模块,在它的APIDemo里也有关于语音识别的sample,不过经过大多开发者的真机测 ...

  8. iOS 10 语音识别Speech Framework详解

    最近做了一个项目,涉及到语音识别,使用的是iOS的speech Framework框架,在网上搜了很多资料,也看了很多博客,但介绍的不是很详细,正好项目做完,在这里给大家详解一下speech Fram ...

  9. Understand User's Intent from Speech and Text

    http://research.microsoft.com/en-us/projects/IntentUnderstanding/ Understanding what users like to d ...

随机推荐

  1. react 可拖拽改变位置和大小的弹窗

    一 目标 最近,项目上需要一个可以弹出一个可以移动位置和改变大小的窗口,来显示一下对当前页面的一个辅助内容 二 思路 1.之前写过一个antd modal的可移动弹窗但是毕竟不如自己写的更定制化,比如 ...

  2. mysql常见的5种日志

    点赞再看,养成习惯,微信搜索「小大白日志」关注这个搬砖人. 文章不定期同步公众号,还有各种一线大厂面试原题.我的学习系列笔记. 错误日志(errorlog) 用来记录mysqlId的错误信息,如数据库 ...

  3. FreeRTOS --(8)任务管理之创建任务

    转载自https://blog.csdn.net/zhoutaopower/article/details/107034995 在<FreeRTOS --(7)任务管理之入门篇>文章基本分 ...

  4. CoreWCF 1.0 正式发布,支持 .NET Core 和 .NET 5+ 的 WCF

    CoreWCF 1.0 正式发布,支持 .NET Core 和 .NET 5+ 的 WCF https://devblogs.microsoft.com/dotnet/corewcf-v1-relea ...

  5. 自己的~/.vimrc

    " 语法高亮syntax on " 搜索高亮set hlsearch " 显示行号set number" let mapleader="," ...

  6. Mockito+Junit5单元测试

    参考: https://segmentfault.com/a/1190000006746409 https://waylau.com/mockito-quick-start/ 1.引入依赖 下面这个最 ...

  7. git clone指定分支

    技术背景 Git是代码版本最常用的管理工具,此前也写过一篇介绍Git的基本使用的博客,而本文介绍一个可能在特定场景下能够用到的功能--直接拉取指定分支的内容. Git Clone 首先看一下如果我们按 ...

  8. intelij idea 好用的插件

    简介 记录一下平时使用的插件 Foldable ProjectView 隐藏目录或文件 One Dark theme 主题比较好用 Gitmoji Plus: Commit Button 在 comm ...

  9. vscode编写的程序中文乱码怎么办?

    (以下教程在源码文件的编码是utf-8的基础上进行!) (dev的源码文件是GBK编码,或者是GB2312?我现在好久没用dev,关于dev的信息可能有错误. 如果拿dev编写的代码用vscode打开 ...

  10. MongoDB 设置用户和密码

    每日一句 Zeal without knowledge is fire without light. 没有知识的热忱犹如火之无光. 给每个数据库设置单独的管理员 我们除了可以设置数据库的超级管理员以外 ...