Zeroth语音到文本库,适用于iOS
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
Example Project
查看项目以了解如何设置与Zeroth服务器的连接以及实时音频流。
依赖管理 & 指令
-
推荐通过CocoaPods包管理器安装Zeroth(类似于大多数库)。创建空白的
Podfile
或使用pod init
命令生成默认的Podfile
。然后添加以下pod信息。pod 'zeroth' pod 'jetfire', :inhibit_warnings => true
-
请记得修改.plist文件以获取用户对使用麦克风的授权,当然,
<String>
的值必须根据您的需求进行定制,您可以通过创建和修改Property List
中的值或右键单击.plist文件,选择Open As
->Source Code
来粘贴以下代码行,并在</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许可证。
版本历史
0.1.0 首个公开版本
版权所有 © 2019 Atlas Guide。保留所有权利。