各大厂的语音识别Speech To Text API使用体验
最近发现有声读物能极大促进我的睡眠,但每个前面都有一段开场语,想把它剪掉,但是有多个开场语,所以就要用到语音识别判断一下再剪。
前两年在本地搭建过识别的环境,奈何识别准确率不行,只能找找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)
优点:识别速度快
缺点:要挂代__理访问,需付费
文档:快速入门:使用客户端库,本地音频文件的话,不要用文档中的代码,可参考我下面的
乱写的示例:
# 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使用体验的更多相关文章
- 利用Google Speech API实现Speech To Text
很久很久以前, 网上流传着一个免费的,识别率暴高的,稳定的 Speech To Text API, 那就是Google Speech API. 但是最近再使用的时候,总是返回500 Error. 后来 ...
- Speech to Text for iOS
找了一下 speech to text 可以用的 SDK for iOS 以下幾種方案: NDEV Mobile (有免費方案,不過似乎不支援離線,客戶清單中有 wallmart,支援不少語言) iS ...
- Csharp: speech to text, text to speech in win
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- mysql connector c++ 1.1 API初步体验
mysql connector c++ 1.1 API初步体验 1,常用的头文件 #include <mysql_connection.h> #include <mysql_driv ...
- 一次神奇的Azure speech to text rest api之旅
错误Max retries exceeded with url: requests.exceptions.ConnectionError: HTTPSConnectionPool(host='%20e ...
- Python 百度语音识别与合成REST API及ffmpeg使用
操作系统:Windows Python:3.5 欢迎加入学习交流QQ群:657341423 百度语音识别官方文档 百度语音合成官方文档 注意事项:接口支持 POST 和 GET两种方式,个人支持用po ...
- <交流贴>android语音识别之科大讯飞语音API的使用
因为最近在研究语音识别,所以借鉴了一下CreAmazing网友的帖子 Android系统本身其实提供有语音识别模块,在它的APIDemo里也有关于语音识别的sample,不过经过大多开发者的真机测 ...
- iOS 10 语音识别Speech Framework详解
最近做了一个项目,涉及到语音识别,使用的是iOS的speech Framework框架,在网上搜了很多资料,也看了很多博客,但介绍的不是很详细,正好项目做完,在这里给大家详解一下speech Fram ...
- Understand User's Intent from Speech and Text
http://research.microsoft.com/en-us/projects/IntentUnderstanding/ Understanding what users like to d ...
随机推荐
- Mysql 计算地址经纬度距离实时位置
前言 最近在做项目时候,遇到一个这样子的需求, 点到卡包里面卡券使用使用,需要展示卡券使用附近门店, 思路 数据库地址表设计 通用的区域街道地址表tz_sys_area 字段名称 类型 备注 area ...
- Linux中几个正则表达式的用法
开源Linux 长按二维码加关注~ 上一篇:盘点提高国内访问Github的速度的9种方案 正则表达式就是用于匹配每行输入的一种模式,模式是指一串字符序列.拥有强大的字符搜索功能.也非常方便的搜索过滤出 ...
- latex中显示代码
如何在latex中添加代码模块 首先在开头导入以下的包 \usepackage{listings} \usepackage{ctex} % 用来设置附录中代码的样式 \lstset{ basicsty ...
- DOM0级同DOM2级
DOM0级分为两个:一是写在标签内的onclick事件: <button id="btn" onclick="alert('happy')">按钮& ...
- Blazor和Vue对比学习(基础1.3):属性和父子传值
组件除了要解决视图层展示.视图层与逻辑层的数据绑定,还需要解决一个重大问题,就是在组件树中实现数据传递,包括了父到子.子到父.祖到孙,以及任意组织之间.而我们上一章讲到的实现双向绑定的两个指令,Vue ...
- Yapi Docker 部署
参考 https://github.com/Ryan-Miao/docker-yapi , 并使用该代码的脚本构建yapi image. 部署mongodb docker run \ --name m ...
- windows 文件hash校验,字符串加密,base64转换工具
对下载的文件使用hash校验验证文件完整性 1 import hashlib 2 def md5(): 3 md5_value = hashlib.md5() 4 with open('C:\Inte ...
- arts-week9
Algorithm 521. Longest Uncommon Subsequence I - LeetCode Review 如何搭建一个私有的CDN? 大部分情况下,我们使用市场上现有的 CDN ...
- 145_Power BI Report Server自定义Form登录
博客:www.jiaopengzi.com 焦棚子的文章目录 请点击下载附件 1.背景 很久没有更新Power BI Report Server了,发现自己机器还是2021年1月版本的,现在更新了20 ...
- 121_Power Query之R.Execute的read.xlsx&ODBC
博客:www.jiaopengzi.com 焦棚子的文章目录 请点击下载附件 一.问题 pq在用 Excel.Workbook 读取一些Excel早期版本(.xls后缀)的文件时候,报错:DataFo ...