iOS 的 Zeroth 语音识别库
Zeroth最初是作为 Atlas 的 对话人工智能平台 的一部分开发的,使企业能够将分析和智能添加到他们的对话数据中。请访问我们的主页了解更多信息。
现在,我们将 Zeroth Cloud 引入作为一个托管服务,任何开发者都可以将其语音识别功能集成到自己的服务中。
我们很乐意听取您的意见!请通过电子邮件[email protected]
与我们联系,提问、提出建议或请求。
特点
- 实时语音识别
- 更改采样率,介于 16000 和 44100 之间
要求
- iOS 10.0+
- Xcode 10.0+
使用方法
首先需要导入头文件。有关如何将 Zeroth 添加到您的项目中,请参阅安装说明。
#import "ZerothSpeechToText.h"
导入后,您可以使用包含您的认证信息的凭证连接到 Zeroth WebSocket 服务器。同时设置代理。可选地,可以配置采样率和缓冲区大小。默认采样率是 16KHz,每 250ms 发送默认缓冲块。
self.zeroth = [ZerothSpeechToText new];
self.zeroth.delegate = self;
// setup sample rate (optional) - default 16 KHz
[self.zeroth setupSampleRate:z16000];
// setup buffer size in second (optional) - default 250 ms
[self.zeroth setupBufferSizeInSecond:0.25];
// setup authentication
[self.zeroth setupAuthenticationAppID:@"ENTER_YOUR_APP_ID"
AppSecret:@"ENTER_YOUR_APP_SECRET"
Language:zKorean //"zKorea" or "zEnglish"
FinalOnly:NO];
// connect to zeroth STT server
[self.zeroth connectZerothSocket];
连接后,需要实现一些代理方法。
zerothSocketDidConnect
- (void)zerothSocketDidConnect {
NSLog(@"socket is connected");
}
zerothSocketDidDisconnectWithError
- (void)zerothSocketDidDisconnectWithError:(NSError*)error {
NSLog(@"zeroth socket is disconnected: %@", [error localizedDescription]);
}
zerothSocketDidReceiveMessage
- (void)zerothSocketDidReceiveMessage:(NSString*)string {
NSLog(@"got some received zeroth result in json: %@", string);
}
zerothSocketDidReceiveData
-(void)zerothSocketDidReceiveData:(NSData*)data {
NSLog(@"got some binary data: %d",data.length);
}
这些代理方法为您提供了在套接字活动发生时处理来自服务器数据的一种简单方式。
connectZerothSocket
[self.zeroth connectZerothSocket]; // create connection to zeroth server
disconnectZerothSocket
[self.zeroth disconnectZerothSocket]; // disconnect from zeroth server
startZerothSTT
[self.zeroth startZerothSTT]; // start listening from mic and send buffer to zeroth server
stopZerothSTT
[self.zeroth stopZerothSTT]; // stop listening and disconnect zeroth socket
示例项目
查看项目了解如何连接到Zeroth服务器以及实时音频流。
依赖管理及指导
-
建议使用CocoaPods包管理器(如多数库)安装Zeroth。创建空的
Podfile
或使用命令pod init
生成默认的Podfile
然后添加以下pod信息。pod 'zeroth' pod 'jetfire', :inhibit_warnings => true
-
请记住修改.plist文件以获取用户麦克风使用授权,当然
<String>
值必须根据您的需求进行定制,您可以通过在Property List
中创建和修改值或在 plist 文件上右键单击,选择“打开方式”->“源代码”,在</dict>
标签之前粘贴以下行来完成此操作。<key>NSMicrophoneUsageDescription</key> <string>Your microphone will be used to analyze voice data </string>
-
创建开发者帐户并生成AppID和AppSecret - 在https://zeroth-console.goodatlas.com
-
连接UI创建简单的功能逻辑
-
要想能够运行项目,您需要iOS 10.0+。
-
构建并运行应用!
-
更详细的说明见代码注释。
依赖
- Jetfire - iOS与OS X的WebSocket (RFC 6455)客户端库
许可
Zeroth for iOS遵循Apache License许可。
版本历史
0.1.0 首次公开发布版本
版权所有 © 2019 Atlas Guide。保留所有权利。