1058 changed files with 143803 additions and 2503 deletions
@ -0,0 +1,90 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# 清理Xcode DerivedData |
||||
|
echo "清理Xcode DerivedData..." |
||||
|
rm -rf ~/Library/Developer/Xcode/DerivedData/* |
||||
|
|
||||
|
# 清理SPM缓存 |
||||
|
echo "清理SPM缓存..." |
||||
|
rm -rf ~/Library/Caches/org.swift.swiftpm/ |
||||
|
|
||||
|
# 进入项目根目录 |
||||
|
cd /Users/wolfplus/Developer/deep_voice |
||||
|
|
||||
|
# 清理各个插件的SPM生成目录 |
||||
|
echo "开始清理各插件的SPM生成目录..." |
||||
|
|
||||
|
# 1. agent_service |
||||
|
echo "清理 agent_service..." |
||||
|
cd local_plugins/agent_service/ios/agent_service |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 2. azure_speech |
||||
|
echo "清理 azure_speech..." |
||||
|
cd local_plugins/azure_speech/ios/azure_speech |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 3. ble_service |
||||
|
echo "清理 ble_service..." |
||||
|
cd local_plugins/ble_service/ios/ble_service |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 4. chat_api |
||||
|
echo "清理 chat_api..." |
||||
|
cd local_plugins/chat_api/ios/chat_api |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 5. chat_storage |
||||
|
echo "清理 chat_storage..." |
||||
|
cd local_plugins/chat_storage/ios/chat_storage |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 6. open_ai_service |
||||
|
echo "清理 open_ai_service..." |
||||
|
cd local_plugins/open_ai_service/ios/open_ai_service |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 7. speech |
||||
|
echo "清理 speech..." |
||||
|
cd local_plugins/speech/ios/speech |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 8. test |
||||
|
echo "清理 test..." |
||||
|
cd local_plugins/test/ios/test |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
echo "所有插件清理完成!" |
||||
|
|
||||
|
# 额外清理项目级别的SPM文件 |
||||
|
echo "清理项目级别的SPM文件..." |
||||
|
rm -rf ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/ |
||||
|
rm -rf ios/Runner.xcworkspace/xcshareddata/swiftpm/ |
||||
|
rm -rf macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/ |
||||
|
rm -rf macos/Runner.xcworkspace/xcshareddata/swiftpm/ |
||||
|
|
||||
|
echo "全部清理完成!" |
||||
@ -1,213 +0,0 @@ |
|||||
{ |
|
||||
"originHash" : "fb7ecff82f4ff109531189491cc6cc2299a7357c61874f58bae1e0f7b7d9e8d0", |
|
||||
"pins" : [ |
|
||||
{ |
|
||||
"identity" : "abseil-cpp-binary", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/abseil-cpp-binary.git", |
|
||||
"state" : { |
|
||||
"revision" : "bbe8b69694d7873315fd3a4ad41efe043e1c07c5", |
|
||||
"version" : "1.2024072200.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "app-check", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/app-check.git", |
|
||||
"state" : { |
|
||||
"revision" : "61b85103a1aeed8218f17c794687781505fbbef5", |
|
||||
"version" : "11.2.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "appauth-ios", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/openid/AppAuth-iOS.git", |
|
||||
"state" : { |
|
||||
"revision" : "2781038865a80e2c425a1da12cc1327bcd56501f", |
|
||||
"version" : "1.7.6" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "dkcamera", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/zhangao0086/DKCamera", |
|
||||
"state" : { |
|
||||
"branch" : "master", |
|
||||
"revision" : "5c691d11014b910aff69f960475d70e65d9dcc96" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "dkimagepickercontroller", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/zhangao0086/DKImagePickerController", |
|
||||
"state" : { |
|
||||
"branch" : "4.3.9", |
|
||||
"revision" : "0bdfeacefa308545adde07bef86e349186335915" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "dkphotogallery", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/zhangao0086/DKPhotoGallery", |
|
||||
"state" : { |
|
||||
"branch" : "master", |
|
||||
"revision" : "311c1bc7a94f1538f82773a79c84374b12a2ef3d" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "firebase-ios-sdk", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/firebase/firebase-ios-sdk", |
|
||||
"state" : { |
|
||||
"revision" : "3663b1aa6c7a1bed67ee80fd09dc6d0f9c3bb660", |
|
||||
"version" : "11.13.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "flutterfire", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/firebase/flutterfire", |
|
||||
"state" : { |
|
||||
"revision" : "a80a123386fd4904cad6938673020a7bcf31b2f2", |
|
||||
"version" : "3.13.0-firebase-core-swift" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "googleappmeasurement", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GoogleAppMeasurement.git", |
|
||||
"state" : { |
|
||||
"revision" : "543071966b3fb6613a2fc5c6e7112d1e998184a7", |
|
||||
"version" : "11.13.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "googledatatransport", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GoogleDataTransport.git", |
|
||||
"state" : { |
|
||||
"revision" : "617af071af9aa1d6a091d59a202910ac482128f9", |
|
||||
"version" : "10.1.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "googlesignin-ios", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GoogleSignIn-iOS.git", |
|
||||
"state" : { |
|
||||
"revision" : "a7965d134c5d3567026c523e0a8a583f73b62b0d", |
|
||||
"version" : "7.1.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "googleutilities", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GoogleUtilities.git", |
|
||||
"state" : { |
|
||||
"revision" : "60da361632d0de02786f709bdc0c4df340f7613e", |
|
||||
"version" : "8.1.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "grpc-binary", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/grpc-binary.git", |
|
||||
"state" : { |
|
||||
"revision" : "cc0001a0cf963aa40501d9c2b181e7fc9fd8ec71", |
|
||||
"version" : "1.69.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "gtm-session-fetcher", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/gtm-session-fetcher.git", |
|
||||
"state" : { |
|
||||
"revision" : "a2ab612cb980066ee56d90d60d8462992c07f24b", |
|
||||
"version" : "3.5.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "gtmappauth", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GTMAppAuth.git", |
|
||||
"state" : { |
|
||||
"revision" : "5d7d66f647400952b1758b230e019b07c0b4b22a", |
|
||||
"version" : "4.1.1" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "interop-ios-for-google-sdks", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/interop-ios-for-google-sdks.git", |
|
||||
"state" : { |
|
||||
"revision" : "040d087ac2267d2ddd4cca36c757d1c6a05fdbfe", |
|
||||
"version" : "101.0.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "leveldb", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/firebase/leveldb.git", |
|
||||
"state" : { |
|
||||
"revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1", |
|
||||
"version" : "1.22.5" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "nanopb", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/firebase/nanopb.git", |
|
||||
"state" : { |
|
||||
"revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1", |
|
||||
"version" : "2.30910.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "promises", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/promises.git", |
|
||||
"state" : { |
|
||||
"revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac", |
|
||||
"version" : "2.4.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "sdwebimage", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/SDWebImage/SDWebImage", |
|
||||
"state" : { |
|
||||
"revision" : "cac9a55a3ae92478a2c95042dcc8d9695d2129ca", |
|
||||
"version" : "5.21.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-protobuf", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/apple/swift-protobuf.git", |
|
||||
"state" : { |
|
||||
"revision" : "d72aed98f8253ec1aa9ea1141e28150f408cf17f", |
|
||||
"version" : "1.29.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swiftygif", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/kirualex/SwiftyGif.git", |
|
||||
"state" : { |
|
||||
"revision" : "4430cbc148baa3907651d40562d96325426f409a", |
|
||||
"version" : "5.4.5" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "tocropviewcontroller", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/TimOliver/TOCropViewController", |
|
||||
"state" : { |
|
||||
"revision" : "a634cb7cdfd580006e79a6e74e64417fe9e9783b", |
|
||||
"version" : "2.7.4" |
|
||||
} |
|
||||
} |
|
||||
], |
|
||||
"version" : 3 |
|
||||
} |
|
||||
@ -1,6 +1,5 @@ |
|||||
class NWApi { |
class NWApi { |
||||
// static const baseApi = "https://www.deapsound.com"; |
// static const baseApi = "https://www.deapsound.com"; |
||||
//测试服务器链接地址,经常修改变动,开发使用 |
|
||||
static const baseApi = "https://api.deapsound.com"; |
static const baseApi = "https://api.deapsound.com"; |
||||
// static const baseApi = "https://api.ideapsound.com"; |
//static const baseApi = "https://api.ideapsound.com"; |
||||
} |
} |
||||
|
|||||
@ -1,4 +0,0 @@ |
|||||
#import <Flutter/Flutter.h> |
|
||||
|
|
||||
@interface AgentServicePlugin : NSObject<FlutterPlugin> |
|
||||
@end |
|
||||
@ -1,12 +0,0 @@ |
|||||
#import "AgentServicePlugin.h" |
|
||||
#if __has_include(<agent_service/agent_service-Swift.h>) |
|
||||
#import <agent_service/agent_service-Swift.h> |
|
||||
#else |
|
||||
#import "agent_service-Swift.h" |
|
||||
#endif |
|
||||
|
|
||||
@implementation AgentServicePlugin |
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar { |
|
||||
[AgentServicePlugin registerWithRegistrar:registrar]; |
|
||||
} |
|
||||
@end |
|
||||
@ -1,240 +0,0 @@ |
|||||
import AVFoundation |
|
||||
import os.log |
|
||||
|
|
||||
public enum AudioIntent { |
|
||||
case voice |
|
||||
case playback |
|
||||
} |
|
||||
|
|
||||
public class AudioSessionHub { |
|
||||
|
|
||||
public static let shared = AudioSessionHub() |
|
||||
|
|
||||
private let logger = OSLog(subsystem: "com.yunqiinnovation.agent_service", category: "AudioSessionHub") |
|
||||
private var currentIntent: AudioIntent? |
|
||||
private let audioSession = AVAudioSession.sharedInstance() |
|
||||
private var isInterrupted = false |
|
||||
|
|
||||
private init() { |
|
||||
setupNotifications() |
|
||||
} |
|
||||
|
|
||||
public func begin(_ intent: AudioIntent) { |
|
||||
if intent == currentIntent && audioSession.isOtherAudioPlaying == false { |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
currentIntent = intent |
|
||||
|
|
||||
do { |
|
||||
switch intent { |
|
||||
|
|
||||
case .voice: |
|
||||
try audioSession.setCategory(.playAndRecord, |
|
||||
mode: .voiceChat, |
|
||||
options: [.allowBluetooth, .mixWithOthers]) |
|
||||
|
|
||||
// 如果有蓝牙HFP设备,强制设置为首选输入 |
|
||||
if let bluetoothInput = audioSession.availableInputs?.first(where: { $0.portType == .bluetoothHFP }) { |
|
||||
try audioSession.setPreferredInput(bluetoothInput) |
|
||||
os_log("已设置蓝牙HFP为首选输入: %{public}@", log: logger, type: .info, bluetoothInput.portName) |
|
||||
} |
|
||||
|
|
||||
case .playback: |
|
||||
try audioSession.setCategory(.playback, |
|
||||
mode: .default, |
|
||||
options: [.allowBluetooth, .mixWithOthers]) |
|
||||
|
|
||||
} |
|
||||
|
|
||||
try audioSession.setActive(true, options: .notifyOthersOnDeactivation) |
|
||||
|
|
||||
os_log("音频会话已设置为:%{public}@", log: logger, type: .debug, String(describing: intent)) |
|
||||
|
|
||||
// 输出当前音频路由信息 |
|
||||
let hasBluetoothDevice = hasBluetoothAudioDevice() |
|
||||
let hasBluetoothMic = hasBluetoothMicrophone() |
|
||||
let currentInput = getCurrentInputDevice() |
|
||||
|
|
||||
os_log("蓝牙音频设备状态: %{public}@", log: logger, type: .info, hasBluetoothDevice ? "已连接" : "未连接") |
|
||||
os_log("蓝牙麦克风状态: %{public}@", log: logger, type: .info, hasBluetoothMic ? "已连接" : "未连接") |
|
||||
os_log("当前输入设备: %{public}@", log: logger, type: .info, currentInput) |
|
||||
|
|
||||
if hasBluetoothDevice { |
|
||||
os_log("%{public}@", log: logger, type: .debug, getCurrentAudioRoute()) |
|
||||
} |
|
||||
} catch { |
|
||||
os_log("设置音频会话失败:%{public}@", log: logger, type: .error, error.localizedDescription) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public func appWillEnterForeground() { |
|
||||
if let intent = currentIntent { |
|
||||
begin(intent) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public func appDidEnterBackground() { |
|
||||
do { |
|
||||
try audioSession.setActive(false, options: .notifyOthersOnDeactivation) |
|
||||
os_log("音频会话已释放(应用进入后台)", log: logger, type: .debug) |
|
||||
} catch { |
|
||||
os_log("释放音频会话失败:%{public}@", log: logger, type: .error, error.localizedDescription) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// 获取当前音频路由信息 |
|
||||
public func getCurrentAudioRoute() -> String { |
|
||||
let currentRoute = audioSession.currentRoute |
|
||||
var routeInfo = "当前音频路由:\n" |
|
||||
|
|
||||
// 输出设备 |
|
||||
routeInfo += "输出设备:\n" |
|
||||
for output in currentRoute.outputs { |
|
||||
routeInfo += " - \(output.portName) (\(output.portType.rawValue))\n" |
|
||||
} |
|
||||
|
|
||||
// 输入设备 |
|
||||
routeInfo += "输入设备:\n" |
|
||||
for input in currentRoute.inputs { |
|
||||
routeInfo += " - \(input.portName) (\(input.portType.rawValue))\n" |
|
||||
} |
|
||||
|
|
||||
return routeInfo |
|
||||
} |
|
||||
|
|
||||
/// 检查是否有蓝牙音频设备连接 |
|
||||
public func hasBluetoothAudioDevice() -> Bool { |
|
||||
let currentRoute = audioSession.currentRoute |
|
||||
|
|
||||
// 检查输出设备 |
|
||||
for output in currentRoute.outputs { |
|
||||
if output.portType == .bluetoothA2DP || |
|
||||
output.portType == .bluetoothHFP || |
|
||||
output.portType == .bluetoothLE { |
|
||||
return true |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// 检查输入设备(这是关键!) |
|
||||
for input in currentRoute.inputs { |
|
||||
if input.portType == .bluetoothHFP { |
|
||||
return true |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return false |
|
||||
} |
|
||||
|
|
||||
/// 检查是否有蓝牙麦克风作为输入设备 |
|
||||
public func hasBluetoothMicrophone() -> Bool { |
|
||||
let currentRoute = audioSession.currentRoute |
|
||||
|
|
||||
for input in currentRoute.inputs { |
|
||||
if input.portType == .bluetoothHFP { |
|
||||
return true |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return false |
|
||||
} |
|
||||
|
|
||||
/// 获取当前输入设备信息 |
|
||||
public func getCurrentInputDevice() -> String { |
|
||||
let currentRoute = audioSession.currentRoute |
|
||||
|
|
||||
if let input = currentRoute.inputs.first { |
|
||||
return "\(input.portName) (\(input.portType.rawValue))" |
|
||||
} |
|
||||
|
|
||||
return "无输入设备" |
|
||||
} |
|
||||
|
|
||||
private func setupNotifications() { |
|
||||
NotificationCenter.default.addObserver( |
|
||||
self, |
|
||||
selector: #selector(handleAudioSessionInterruption), |
|
||||
name: AVAudioSession.interruptionNotification, |
|
||||
object: nil |
|
||||
) |
|
||||
|
|
||||
NotificationCenter.default.addObserver( |
|
||||
self, |
|
||||
selector: #selector(handleAudioRouteChange), |
|
||||
name: AVAudioSession.routeChangeNotification, |
|
||||
object: nil |
|
||||
) |
|
||||
} |
|
||||
|
|
||||
/// 处理音频中断 |
|
||||
@objc private func handleAudioSessionInterruption(notification: Notification) { |
|
||||
guard let userInfo = notification.userInfo, |
|
||||
let typeValue = userInfo[AVAudioSessionInterruptionTypeKey] as? UInt, |
|
||||
let type = AVAudioSession.InterruptionType(rawValue: typeValue) else { |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
switch type { |
|
||||
case .began: |
|
||||
// 中断开始 |
|
||||
isInterrupted = true |
|
||||
os_log("音频会话被中断", log: logger, type: .debug) |
|
||||
|
|
||||
case .ended: |
|
||||
// 中断结束 |
|
||||
isInterrupted = false |
|
||||
|
|
||||
// 检查是否应该恢复 |
|
||||
if let optionsValue = userInfo[AVAudioSessionInterruptionOptionKey] as? UInt { |
|
||||
let options = AVAudioSession.InterruptionOptions(rawValue: optionsValue) |
|
||||
if options.contains(.shouldResume), let intent = currentIntent { |
|
||||
// 恢复之前的音频意图 |
|
||||
begin(intent) |
|
||||
os_log("音频会话中断结束,已恢复", log: logger, type: .debug) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@unknown default: |
|
||||
os_log("未知的音频中断类型: %{public}@", log: logger, type: .error, "\(type)") |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// 处理音频路由变化 |
|
||||
@objc private func handleAudioRouteChange(notification: Notification) { |
|
||||
guard let userInfo = notification.userInfo, |
|
||||
let reasonValue = userInfo[AVAudioSessionRouteChangeReasonKey] as? UInt, |
|
||||
let reason = AVAudioSession.RouteChangeReason(rawValue: reasonValue) else { |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
switch reason { |
|
||||
case .newDeviceAvailable: |
|
||||
os_log("新音频设备已连接", log: logger, type: .info) |
|
||||
os_log("%{public}@", log: logger, type: .debug, getCurrentAudioRoute()) |
|
||||
|
|
||||
// 重新应用当前意图以确保正确路由 |
|
||||
if let intent = currentIntent { |
|
||||
begin(intent) |
|
||||
} |
|
||||
|
|
||||
case .oldDeviceUnavailable: |
|
||||
os_log("音频设备已断开", log: logger, type: .info) |
|
||||
os_log("%{public}@", log: logger, type: .debug, getCurrentAudioRoute()) |
|
||||
|
|
||||
// 重新应用当前意图以确保正确路由 |
|
||||
if let intent = currentIntent { |
|
||||
begin(intent) |
|
||||
} |
|
||||
|
|
||||
case .categoryChange: |
|
||||
os_log("音频类别已变化", log: logger, type: .info) |
|
||||
|
|
||||
default: |
|
||||
break |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
deinit { |
|
||||
NotificationCenter.default.removeObserver(self) |
|
||||
} |
|
||||
} |
|
||||
@ -1,29 +0,0 @@ |
|||||
# |
|
||||
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. |
|
||||
# Run `pod lib lint agent_service.podspec` to validate before publishing. |
|
||||
# |
|
||||
Pod::Spec.new do |s| |
|
||||
s.name = 'agent_service' |
|
||||
s.version = '0.0.1' |
|
||||
s.summary = '智能助手代理服务' |
|
||||
s.description = <<-DESC |
|
||||
智能助手代理服务,提供语音识别、语音合成和OpenAI对话功能 |
|
||||
DESC |
|
||||
s.homepage = 'http://example.com' |
|
||||
s.license = { :file => '../LICENSE' } |
|
||||
s.author = { 'Your Company' => 'email@example.com' } |
|
||||
s.source = { :path => '.' } |
|
||||
s.source_files = 'Classes/**/*.swift' |
|
||||
s.resources = ['Resources/*.mp3'] |
|
||||
|
|
||||
s.dependency 'Flutter' |
|
||||
s.dependency 'azure_speech' |
|
||||
s.dependency 'ble_service' |
|
||||
s.dependency 'open_ai_service' |
|
||||
s.dependency 'chat_storage' |
|
||||
s.platform = :ios, '13.0' |
|
||||
|
|
||||
# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. |
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' } |
|
||||
s.swift_version = '5.0' |
|
||||
end |
|
||||
@ -0,0 +1,37 @@ |
|||||
|
// swift-tools-version: 5.9 |
||||
|
import PackageDescription |
||||
|
|
||||
|
let package = Package( |
||||
|
name: "agent_service", |
||||
|
platforms: [.iOS("18.0")], |
||||
|
products: [ |
||||
|
.library(name: "agent-service", targets: ["agent_service"]) |
||||
|
], |
||||
|
dependencies: [ |
||||
|
.package(path: "../../../test/ios/test"), |
||||
|
.package(path: "../../../ble_service/ios/ble_service"), |
||||
|
.package(path: "../../../speech/ios/speech"), |
||||
|
.package(path: "../../../azure_speech/ios/azure_speech"), |
||||
|
.package(path: "../../../chat_api/ios/chat_api"), |
||||
|
.package(path: "../../../chat_storage/ios/chat_storage") |
||||
|
], |
||||
|
targets: [ |
||||
|
.target( |
||||
|
name: "agent_service", |
||||
|
dependencies: [ |
||||
|
.product(name: "test", package: "test"), |
||||
|
.product(name: "ble-service", package: "ble_service"), |
||||
|
.product(name: "speech", package: "speech"), |
||||
|
.product(name: "azure-speech", package: "azure_speech"), |
||||
|
.product(name: "chat-api", package: "chat_api"), |
||||
|
.product(name: "chat-storage", package: "chat_storage") |
||||
|
], |
||||
|
path: "Sources/agent_service", |
||||
|
resources: [ |
||||
|
.copy("Resources/calling.mp3"), |
||||
|
.copy("Resources/start.mp3"), |
||||
|
.copy("Resources/stop.mp3") |
||||
|
] |
||||
|
) |
||||
|
] |
||||
|
) |
||||
@ -0,0 +1,437 @@ |
|||||
|
import AVFoundation |
||||
|
import os.log |
||||
|
|
||||
|
public enum AudioIntent { |
||||
|
case voice |
||||
|
case playback |
||||
|
} |
||||
|
|
||||
|
public class AudioSessionHub { |
||||
|
|
||||
|
public static let shared = AudioSessionHub() |
||||
|
|
||||
|
private let logger = OSLog(subsystem: "com.yunqiinnovation.agent_service", category: "AudioSessionHub") |
||||
|
private var currentIntent: AudioIntent? |
||||
|
private let audioSession = AVAudioSession.sharedInstance() |
||||
|
private var isInterrupted = false |
||||
|
|
||||
|
private init() { |
||||
|
setupNotifications() |
||||
|
} |
||||
|
|
||||
|
public func begin(_ intent: AudioIntent) { |
||||
|
if intent == currentIntent && audioSession.isOtherAudioPlaying == false { |
||||
|
os_log("音频意图未变化且无其他音频播放,跳过设置: %{public}@", log: logger, type: .debug, String(describing: intent)) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
os_log("开始设置音频会话,意图: %{public}@", log: logger, type: .info, String(describing: intent)) |
||||
|
currentIntent = intent |
||||
|
|
||||
|
do { |
||||
|
switch intent { |
||||
|
|
||||
|
case .voice: |
||||
|
os_log("设置语音模式: category=playAndRecord, mode=voiceChat", log: logger, type: .info) |
||||
|
|
||||
|
// 第一步:设置音频类别和模式 |
||||
|
try audioSession.setCategory(.playAndRecord, |
||||
|
mode: .voiceChat, |
||||
|
options: [.allowBluetooth, .defaultToSpeaker, .mixWithOthers]) |
||||
|
os_log("✓ 音频类别设置成功: playAndRecord + voiceChat", log: logger, type: .info) |
||||
|
|
||||
|
// 第二步:检查并设置蓝牙输入 |
||||
|
os_log("检查可用输入设备...", log: logger, type: .info) |
||||
|
if let availableInputs = audioSession.availableInputs { |
||||
|
os_log("可用输入设备数量: %d", log: logger, type: .info, availableInputs.count) |
||||
|
for (index, input) in availableInputs.enumerated() { |
||||
|
os_log("输入设备[%d]: %{public}@ (%{public}@)", log: logger, type: .info, |
||||
|
index, input.portName, input.portType.rawValue) |
||||
|
} |
||||
|
|
||||
|
// 查找蓝牙HFP设备 |
||||
|
if let bluetoothInput = availableInputs.first(where: { $0.portType == .bluetoothHFP }) { |
||||
|
os_log("找到蓝牙HFP设备,尝试设置为首选输入: %{public}@", log: logger, type: .info, bluetoothInput.portName) |
||||
|
try audioSession.setPreferredInput(bluetoothInput) |
||||
|
os_log("✓ 蓝牙HFP输入设置成功: %{public}@", log: logger, type: .info, bluetoothInput.portName) |
||||
|
} else { |
||||
|
os_log("未找到蓝牙HFP设备", log: logger, type: .info) |
||||
|
} |
||||
|
} else { |
||||
|
os_log("⚠️ availableInputs 为 nil", log: logger, type: .default) |
||||
|
} |
||||
|
|
||||
|
case .playback: |
||||
|
os_log("设置播放模式: category=playback, mode=default", log: logger, type: .info) |
||||
|
|
||||
|
// 检查当前音频会话状态 |
||||
|
os_log("设置前状态检查:", log: logger, type: .info) |
||||
|
os_log(" - 当前类别: %{public}@", log: logger, type: .info, audioSession.category.rawValue) |
||||
|
os_log(" - 当前模式: %{public}@", log: logger, type: .info, audioSession.mode.rawValue) |
||||
|
os_log(" - 当前是否激活: %{public}@", log: logger, type: .info, audioSession.isOtherAudioPlaying ? "是" : "否") |
||||
|
os_log(" - 其他音频播放: %{public}@", log: logger, type: .info, audioSession.isOtherAudioPlaying ? "是" : "否") |
||||
|
|
||||
|
// 如果当前已经激活,先尝试停用 |
||||
|
do { |
||||
|
if audioSession.isOtherAudioPlaying { |
||||
|
os_log("检测到其他音频正在播放,先尝试停用当前会话", log: logger, type: .info) |
||||
|
try audioSession.setActive(false, options: .notifyOthersOnDeactivation) |
||||
|
os_log("✓ 成功停用当前音频会话", log: logger, type: .info) |
||||
|
} |
||||
|
} catch let deactivateError as NSError { |
||||
|
os_log("⚠️ 停用当前音频会话失败: %{public}@ (继续尝试设置)", log: logger, type: .default, deactivateError.localizedDescription) |
||||
|
} |
||||
|
|
||||
|
// 尝试渐进式设置:先尝试最简单的设置 |
||||
|
var settingSuccess = false |
||||
|
|
||||
|
// 策略1: 只设置类别,不设置选项 |
||||
|
if !settingSuccess { |
||||
|
do { |
||||
|
os_log("尝试策略1: 仅设置类别 (playback)", log: logger, type: .info) |
||||
|
try audioSession.setCategory(.playback) |
||||
|
os_log("✓ 策略1成功: 音频类别设置为 playback", log: logger, type: .info) |
||||
|
settingSuccess = true |
||||
|
} catch let error as NSError { |
||||
|
os_log("策略1失败: %{public}@ (OSStatus: %d)", log: logger, type: .info, error.localizedDescription, error.code) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 策略2: 设置类别和模式,不设置选项 |
||||
|
if !settingSuccess { |
||||
|
do { |
||||
|
os_log("尝试策略2: 设置类别和模式 (playback + default)", log: logger, type: .info) |
||||
|
try audioSession.setCategory(.playback, mode: .default) |
||||
|
os_log("✓ 策略2成功: 音频类别和模式设置完成", log: logger, type: .info) |
||||
|
settingSuccess = true |
||||
|
} catch let error as NSError { |
||||
|
os_log("策略2失败: %{public}@ (OSStatus: %d)", log: logger, type: .info, error.localizedDescription, error.code) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 策略3: 设置类别、模式和单个选项 |
||||
|
if !settingSuccess { |
||||
|
do { |
||||
|
os_log("尝试策略3: 设置类别、模式和混音选项", log: logger, type: .info) |
||||
|
try audioSession.setCategory(.playback, mode: .default, options: [.mixWithOthers]) |
||||
|
os_log("✓ 策略3成功: 音频类别、模式和混音选项设置完成", log: logger, type: .info) |
||||
|
settingSuccess = true |
||||
|
} catch let error as NSError { |
||||
|
os_log("策略3失败: %{public}@ (OSStatus: %d)", log: logger, type: .info, error.localizedDescription, error.code) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 策略4: 设置类别、模式和蓝牙选项 |
||||
|
if !settingSuccess { |
||||
|
do { |
||||
|
os_log("尝试策略4: 设置类别、模式和蓝牙选项", log: logger, type: .info) |
||||
|
try audioSession.setCategory(.playback, mode: .default, options: [.allowBluetoothA2DP]) |
||||
|
os_log("✓ 策略4成功: 音频类别、模式和蓝牙选项设置完成", log: logger, type: .info) |
||||
|
settingSuccess = true |
||||
|
} catch let error as NSError { |
||||
|
os_log("策略4失败: %{public}@ (OSStatus: %d)", log: logger, type: .info, error.localizedDescription, error.code) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 策略5: 完整设置(原始方案) |
||||
|
if !settingSuccess { |
||||
|
os_log("尝试策略5: 完整设置 (playback + default + 所有选项)", log: logger, type: .info) |
||||
|
try audioSession.setCategory(.playback, |
||||
|
mode: .default, |
||||
|
options: [.allowBluetoothA2DP, .mixWithOthers]) |
||||
|
os_log("✓ 策略5成功: 完整音频设置完成", log: logger, type: .info) |
||||
|
settingSuccess = true |
||||
|
} |
||||
|
|
||||
|
if !settingSuccess { |
||||
|
os_log("❌ 所有设置策略都失败了", log: logger, type: .error) |
||||
|
throw NSError(domain: "AudioSessionHub", code: -1, userInfo: [NSLocalizedDescriptionKey: "所有音频类别设置策略都失败"]) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// 第三步:激活音频会话 |
||||
|
os_log("尝试激活音频会话...", log: logger, type: .info) |
||||
|
try audioSession.setActive(true, options: .notifyOthersOnDeactivation) |
||||
|
os_log("✓ 音频会话激活成功", log: logger, type: .info) |
||||
|
|
||||
|
os_log("✅ 音频会话完整设置成功:%{public}@", log: logger, type: .info, String(describing: intent)) |
||||
|
|
||||
|
// 输出当前音频路由信息 |
||||
|
let hasBluetoothDevice = hasBluetoothAudioDevice() |
||||
|
let hasBluetoothMic = hasBluetoothMicrophone() |
||||
|
let currentInput = getCurrentInputDevice() |
||||
|
|
||||
|
os_log("📊 音频状态总览:", log: logger, type: .info) |
||||
|
os_log(" - 蓝牙音频设备: %{public}@", log: logger, type: .info, hasBluetoothDevice ? "已连接" : "未连接") |
||||
|
os_log(" - 蓝牙麦克风: %{public}@", log: logger, type: .info, hasBluetoothMic ? "已连接" : "未连接") |
||||
|
os_log(" - 当前输入设备: %{public}@", log: logger, type: .info, currentInput) |
||||
|
|
||||
|
if hasBluetoothDevice { |
||||
|
os_log("📋 详细路由信息:\n%{public}@", log: logger, type: .debug, getCurrentAudioRoute()) |
||||
|
} |
||||
|
} catch let error as NSError { |
||||
|
let osStatusCode = error.code |
||||
|
let domain = error.domain |
||||
|
let description = error.localizedDescription |
||||
|
|
||||
|
os_log("❌ 设置音频会话失败", log: logger, type: .error) |
||||
|
os_log(" - 错误域: %{public}@", log: logger, type: .error, domain) |
||||
|
os_log(" - OSStatus代码: %d (0x%X)", log: logger, type: .error, osStatusCode, osStatusCode) |
||||
|
os_log(" - 错误描述: %{public}@", log: logger, type: .error, description) |
||||
|
os_log(" - 当前意图: %{public}@", log: logger, type: .error, String(describing: intent)) |
||||
|
|
||||
|
// 解析具体的 OSStatus 错误 |
||||
|
switch osStatusCode { |
||||
|
case -50: |
||||
|
os_log(" ➤ 错误分析: OSStatus -50 通常表示参数错误 (kAudioSessionInvalidPropertyError)", log: logger, type: .error) |
||||
|
case -560557673: // kAudioSessionNotInitialized |
||||
|
os_log(" ➤ 错误分析: 音频会话未初始化", log: logger, type: .error) |
||||
|
case -560030580: // kAudioSessionBadPropertySizeError |
||||
|
os_log(" ➤ 错误分析: 属性大小错误", log: logger, type: .error) |
||||
|
case -560161140: // kAudioSessionIncompatibleCategory |
||||
|
os_log(" ➤ 错误分析: 音频类别不兼容", log: logger, type: .error) |
||||
|
default: |
||||
|
os_log(" ➤ 错误分析: 未知的OSStatus错误代码", log: logger, type: .error) |
||||
|
} |
||||
|
|
||||
|
// 输出当前音频会话状态用于调试 |
||||
|
os_log("🔍 当前音频会话状态:", log: logger, type: .error) |
||||
|
os_log(" - 类别: %{public}@", log: logger, type: .error, audioSession.category.rawValue) |
||||
|
os_log(" - 模式: %{public}@", log: logger, type: .error, audioSession.mode.rawValue) |
||||
|
os_log(" - 是否激活: %{public}@", log: logger, type: .error, audioSession.isOtherAudioPlaying ? "是" : "否") |
||||
|
os_log(" - 其他音频播放: %{public}@", log: logger, type: .error, audioSession.isOtherAudioPlaying ? "是" : "否") |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public func appWillEnterForeground() { |
||||
|
os_log("📱 应用即将进入前台", log: logger, type: .info) |
||||
|
if let intent = currentIntent { |
||||
|
os_log("恢复之前的音频意图: %{public}@", log: logger, type: .info, String(describing: intent)) |
||||
|
begin(intent) |
||||
|
} else { |
||||
|
os_log("无之前的音频意图需要恢复", log: logger, type: .info) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public func appDidEnterBackground() { |
||||
|
os_log("📱 应用进入后台,准备释放音频会话", log: logger, type: .info) |
||||
|
do { |
||||
|
try audioSession.setActive(false, options: .notifyOthersOnDeactivation) |
||||
|
os_log("✓ 音频会话已释放(应用进入后台)", log: logger, type: .info) |
||||
|
} catch let error as NSError { |
||||
|
let osStatusCode = error.code |
||||
|
let domain = error.domain |
||||
|
let description = error.localizedDescription |
||||
|
|
||||
|
os_log("❌ 释放音频会话失败", log: logger, type: .error) |
||||
|
os_log(" - 错误域: %{public}@", log: logger, type: .error, domain) |
||||
|
os_log(" - OSStatus代码: %d (0x%X)", log: logger, type: .error, osStatusCode, osStatusCode) |
||||
|
os_log(" - 错误描述: %{public}@", log: logger, type: .error, description) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// 获取当前音频路由信息 |
||||
|
public func getCurrentAudioRoute() -> String { |
||||
|
let currentRoute = audioSession.currentRoute |
||||
|
var routeInfo = "当前音频路由:\n" |
||||
|
|
||||
|
// 输出设备 |
||||
|
routeInfo += "输出设备:\n" |
||||
|
for output in currentRoute.outputs { |
||||
|
routeInfo += " - \(output.portName) (\(output.portType.rawValue))\n" |
||||
|
} |
||||
|
|
||||
|
// 输入设备 |
||||
|
routeInfo += "输入设备:\n" |
||||
|
for input in currentRoute.inputs { |
||||
|
routeInfo += " - \(input.portName) (\(input.portType.rawValue))\n" |
||||
|
} |
||||
|
|
||||
|
return routeInfo |
||||
|
} |
||||
|
|
||||
|
/// 检查是否有蓝牙音频设备连接 |
||||
|
public func hasBluetoothAudioDevice() -> Bool { |
||||
|
let currentRoute = audioSession.currentRoute |
||||
|
|
||||
|
// 检查输出设备 |
||||
|
for output in currentRoute.outputs { |
||||
|
if output.portType == .bluetoothA2DP || |
||||
|
output.portType == .bluetoothHFP || |
||||
|
output.portType == .bluetoothLE { |
||||
|
return true |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 检查输入设备(这是关键!) |
||||
|
for input in currentRoute.inputs { |
||||
|
if input.portType == .bluetoothHFP { |
||||
|
return true |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return false |
||||
|
} |
||||
|
|
||||
|
/// 检查是否有蓝牙麦克风作为输入设备 |
||||
|
public func hasBluetoothMicrophone() -> Bool { |
||||
|
let currentRoute = audioSession.currentRoute |
||||
|
|
||||
|
for input in currentRoute.inputs { |
||||
|
if input.portType == .bluetoothHFP { |
||||
|
return true |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return false |
||||
|
} |
||||
|
|
||||
|
/// 获取当前输入设备信息 |
||||
|
public func getCurrentInputDevice() -> String { |
||||
|
let currentRoute = audioSession.currentRoute |
||||
|
|
||||
|
if let input = currentRoute.inputs.first { |
||||
|
return "\(input.portName) (\(input.portType.rawValue))" |
||||
|
} |
||||
|
|
||||
|
return "无输入设备" |
||||
|
} |
||||
|
|
||||
|
private func setupNotifications() { |
||||
|
NotificationCenter.default.addObserver( |
||||
|
self, |
||||
|
selector: #selector(handleAudioSessionInterruption), |
||||
|
name: AVAudioSession.interruptionNotification, |
||||
|
object: nil |
||||
|
) |
||||
|
|
||||
|
NotificationCenter.default.addObserver( |
||||
|
self, |
||||
|
selector: #selector(handleAudioRouteChange), |
||||
|
name: AVAudioSession.routeChangeNotification, |
||||
|
object: nil |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
/// 处理音频中断 |
||||
|
@objc private func handleAudioSessionInterruption(notification: Notification) { |
||||
|
os_log("🔊 收到音频会话中断通知", log: logger, type: .info) |
||||
|
|
||||
|
guard let userInfo = notification.userInfo, |
||||
|
let typeValue = userInfo[AVAudioSessionInterruptionTypeKey] as? UInt, |
||||
|
let type = AVAudioSession.InterruptionType(rawValue: typeValue) else { |
||||
|
os_log("⚠️ 无法解析音频中断通知", log: logger, type: .default) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
switch type { |
||||
|
case .began: |
||||
|
// 中断开始 |
||||
|
isInterrupted = true |
||||
|
os_log("🚫 音频会话中断开始", log: logger, type: .info) |
||||
|
os_log(" - 中断状态: %{public}@", log: logger, type: .info, isInterrupted ? "是" : "否") |
||||
|
|
||||
|
case .ended: |
||||
|
// 中断结束 |
||||
|
isInterrupted = false |
||||
|
os_log("✅ 音频会话中断结束", log: logger, type: .info) |
||||
|
|
||||
|
// 检查是否应该恢复 |
||||
|
if let optionsValue = userInfo[AVAudioSessionInterruptionOptionKey] as? UInt { |
||||
|
let options = AVAudioSession.InterruptionOptions(rawValue: optionsValue) |
||||
|
os_log("中断选项: %d, 应该恢复: %{public}@", log: logger, type: .info, optionsValue, options.contains(.shouldResume) ? "是" : "否") |
||||
|
|
||||
|
if options.contains(.shouldResume), let intent = currentIntent { |
||||
|
os_log("恢复之前的音频意图: %{public}@", log: logger, type: .info, String(describing: intent)) |
||||
|
// 恢复之前的音频意图 |
||||
|
begin(intent) |
||||
|
os_log("✓ 音频会话中断结束,已恢复", log: logger, type: .info) |
||||
|
} else { |
||||
|
os_log("不需要恢复音频会话", log: logger, type: .info) |
||||
|
} |
||||
|
} else { |
||||
|
os_log("⚠️ 中断通知中无选项信息", log: logger, type: .default) |
||||
|
} |
||||
|
|
||||
|
@unknown default: |
||||
|
os_log("❓ 未知的音频中断类型: %{public}@", log: logger, type: .error, "\(type)") |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// 处理音频路由变化 |
||||
|
@objc private func handleAudioRouteChange(notification: Notification) { |
||||
|
os_log("🔄 收到音频路由变化通知", log: logger, type: .info) |
||||
|
|
||||
|
guard let userInfo = notification.userInfo, |
||||
|
let reasonValue = userInfo[AVAudioSessionRouteChangeReasonKey] as? UInt, |
||||
|
let reason = AVAudioSession.RouteChangeReason(rawValue: reasonValue) else { |
||||
|
os_log("⚠️ 无法解析音频路由变化通知", log: logger, type: .default) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
os_log("路由变化原因: %d (%{public}@)", log: logger, type: .info, reasonValue, "\(reason)") |
||||
|
|
||||
|
switch reason { |
||||
|
case .newDeviceAvailable: |
||||
|
os_log("📱 新音频设备已连接", log: logger, type: .info) |
||||
|
os_log("📋 当前音频路由:\n%{public}@", log: logger, type: .info, getCurrentAudioRoute()) |
||||
|
|
||||
|
// 重新应用当前意图以确保正确路由 |
||||
|
if let intent = currentIntent { |
||||
|
os_log("重新应用当前音频意图: %{public}@", log: logger, type: .info, String(describing: intent)) |
||||
|
begin(intent) |
||||
|
} else { |
||||
|
os_log("无当前音频意图需要重新应用", log: logger, type: .info) |
||||
|
} |
||||
|
|
||||
|
case .oldDeviceUnavailable: |
||||
|
os_log("📱 音频设备已断开", log: logger, type: .info) |
||||
|
|
||||
|
// 输出之前的路由信息(如果可用) |
||||
|
if let previousRoute = userInfo[AVAudioSessionRouteChangePreviousRouteKey] as? AVAudioSessionRouteDescription { |
||||
|
os_log("之前的音频路由:", log: logger, type: .info) |
||||
|
for output in previousRoute.outputs { |
||||
|
os_log(" - 输出: %{public}@ (%{public}@)", log: logger, type: .info, output.portName, output.portType.rawValue) |
||||
|
} |
||||
|
for input in previousRoute.inputs { |
||||
|
os_log(" - 输入: %{public}@ (%{public}@)", log: logger, type: .info, input.portName, input.portType.rawValue) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
os_log("📋 当前音频路由:\n%{public}@", log: logger, type: .info, getCurrentAudioRoute()) |
||||
|
|
||||
|
// 重新应用当前意图以确保正确路由 |
||||
|
if let intent = currentIntent { |
||||
|
os_log("重新应用当前音频意图: %{public}@", log: logger, type: .info, String(describing: intent)) |
||||
|
begin(intent) |
||||
|
} else { |
||||
|
os_log("无当前音频意图需要重新应用", log: logger, type: .info) |
||||
|
} |
||||
|
|
||||
|
case .categoryChange: |
||||
|
os_log("🔧 音频类别已变化", log: logger, type: .info) |
||||
|
os_log(" - 当前类别: %{public}@", log: logger, type: .info, audioSession.category.rawValue) |
||||
|
os_log(" - 当前模式: %{public}@", log: logger, type: .info, audioSession.mode.rawValue) |
||||
|
|
||||
|
case .override: |
||||
|
os_log("🔀 音频路由被覆盖", log: logger, type: .info) |
||||
|
|
||||
|
case .wakeFromSleep: |
||||
|
os_log("😴 从睡眠中唤醒", log: logger, type: .info) |
||||
|
|
||||
|
case .noSuitableRouteForCategory: |
||||
|
os_log("❌ 当前类别没有合适的路由", log: logger, type: .default) |
||||
|
|
||||
|
case .routeConfigurationChange: |
||||
|
os_log("⚙️ 路由配置发生变化", log: logger, type: .info) |
||||
|
|
||||
|
@unknown default: |
||||
|
os_log("❓ 未知的路由变化原因: %d", log: logger, type: .default) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
deinit { |
||||
|
NotificationCenter.default.removeObserver(self) |
||||
|
} |
||||
|
} |
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,29 +0,0 @@ |
|||||
# |
|
||||
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. |
|
||||
# Run `pod lib lint azure_speech.podspec` to validate before publishing. |
|
||||
# |
|
||||
Pod::Spec.new do |s| |
|
||||
s.name = 'azure_speech' |
|
||||
s.version = '0.0.1' |
|
||||
s.summary = 'Azure Speech SDK Flutter plugin' |
|
||||
s.description = <<-DESC |
|
||||
A Flutter plugin for Azure Speech Services providing speech recognition and text-to-speech capabilities. |
|
||||
DESC |
|
||||
s.homepage = 'https://github.com/yunqiinnovation/azure_speech' |
|
||||
s.license = { :file => '../LICENSE' } |
|
||||
s.author = { 'Your Company' => 'email@example.com' } |
|
||||
s.source = { :path => '.' } |
|
||||
s.source_files = 'Classes/**/*.{swift}' |
|
||||
s.dependency 'Flutter' |
|
||||
s.dependency 'speech' |
|
||||
s.dependency 'MicrosoftCognitiveServicesSpeech-iOS', '~> 1.37.0' |
|
||||
s.platform = :ios, '11.0' |
|
||||
|
|
||||
# Flutter.framework does not contain a i386 slice. |
|
||||
s.pod_target_xcconfig = { |
|
||||
'DEFINES_MODULE' => 'YES', |
|
||||
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', |
|
||||
'SWIFT_EMIT_LOC_STRINGS' => 'YES' |
|
||||
} |
|
||||
s.swift_version = '5.0' |
|
||||
end |
|
||||
@ -0,0 +1,120 @@ |
|||||
|
# MICROSOFT SOFTWARE LICENSE TERMS |
||||
|
|
||||
|
MICROSOFT COGNITIVE SERVICES SPEECH SDK |
||||
|
|
||||
|
**IF YOU LIVE IN (OR ARE A BUSINESS WITH A PRINCIPAL PLACE OF BUSINESS IN) THE UNITED STATES, PLEASE READ THE "BINDING ARBITRATION AND CLASS ACTION WAIVER" SECTION BELOW. IT AFFECTS HOW DISPUTES ARE RESOLVED.** |
||||
|
|
||||
|
These license terms are an agreement between you and Microsoft Corporation (or one of its affiliates). They apply to the software named above and any Microsoft services or software updates (except to the extent such services or updates are accompanied by new or additional terms, in which case those different terms apply prospectively and do not alter your or Microsoft's rights relating to pre-updated software or services). IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. |
||||
|
|
||||
|
## 1. INSTALLATION AND USE RIGHTS. |
||||
|
|
||||
|
**a) General.** You may install and use any number of copies of the software to develop and test your applications that integrate API(s) used to access and/or use Cognitive Services Speech Services including Embedded Speech Components. |
||||
|
|
||||
|
**b) Third Party Components.** The software may include third party components with separate legal notices or governed by other agreements, as may be described in the ThirdPartyNotices file(s) accompanying the software or may be accessible at <http://aka.ms/thirdpartynotices>. Even if such components are governed by other agreements, the disclaimer, limitations on, and exclusions of damages below also apply to the extent allowed by applicable law. |
||||
|
|
||||
|
**c) Competitive Benchmarking**. If you are a direct competitor, and you access or use the software for purposes of competitive benchmarking, analysis, or intelligence gathering, you waive as against Microsoft, its subsidiaries, and its affiliated companies (including prospectively) any competitive use, access, and benchmarking test restrictions in the terms governing your software to the extent your terms of use are, or purport to be, more restrictive than Microsoft's terms. If this section applies and you do not waive any such purported restrictions in the terms governing your software, you are not allowed to access or use this software, and will not do so. |
||||
|
|
||||
|
## 2. DISTRIBUTABLE CODE. |
||||
|
|
||||
|
The software may contain code you are permitted to distribute (i.e., make available for third parties) in applications you develop, as described in this Section. |
||||
|
|
||||
|
**a) Distribution Rights.** The code and test files described below are distributable if included with the software. |
||||
|
|
||||
|
i. REDIST.TXT Files. You may copy and distribute the object code form of code listed on the REDIST list in the software, if any; and |
||||
|
|
||||
|
ii. Third Party Distribution. You may permit distributors of your applications to copy and distribute any of this distributable code you elect to distribute with your applications. |
||||
|
|
||||
|
**b) Distribution Requirements.** For any code you distribute, you must: |
||||
|
|
||||
|
i. add significant primary functionality to it in your applications; |
||||
|
|
||||
|
ii. require distributors and external end users to agree to terms that protect it and Microsoft at least as much as this agreement; and |
||||
|
|
||||
|
iii. indemnify, defend, and hold harmless Microsoft from any claims, including attorneys' fees, related to the distribution or use of your applications, except to the extent that any claim is based solely on the unmodified distributable code. |
||||
|
|
||||
|
**c) Distribution Restrictions.** You may not: |
||||
|
|
||||
|
i. use Microsoft's trademarks or trade dress in your application in any way that suggests your application comes from or is endorsed by Microsoft; or |
||||
|
|
||||
|
ii. modify or distribute the source code of any distributable code so that any part of it becomes subject to any license that requires that the distributable code, any other part of the software, or any of Microsoft's other intellectual property be disclosed or distributed in source code form, or that others have the right to modify it. |
||||
|
|
||||
|
## 3. CONDITIONAL RIGHTS TO USE AND DISTRIBUTE EMBEDDED SPEECH COMPONENTS. |
||||
|
If you are approved for access to Embedded Speech Components in accordance with the terms for Limited Access Services in the Service-Specific Product Terms for Azure Cognitive Services and Applied AI Services available at https://www.microsoft.com/licensing/terms/welcome/welcomepage, and you are in compliance with these license terms, you may license the additional rights to use and distribute the Embedded Speech Components provided to you by Microsoft. Additional applicable terms and conditions will be made available to you upon approval to access Embedded Speech Components. |
||||
|
|
||||
|
**a)** The rights and obligations set forth in this section 3 are in addition to and subject to all other provisions of these SDK license terms except to the extent of any conflict, in which case the provisions of this section 3 will control. To the extent of any conflict between the rights and obligations set forth in this section 3 and the applicable license agreement, the provisions of the applicable license agreement will control. |
||||
|
|
||||
|
## 4. SCOPE OF LICENSE. |
||||
|
|
||||
|
The software is licensed, not sold. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you will not (and have no right to): |
||||
|
|
||||
|
**a)** work around any technical limitations in the software that only allow you to use it in certain ways; |
||||
|
|
||||
|
**b)** reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software; |
||||
|
|
||||
|
**c)** remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software; |
||||
|
|
||||
|
**d)** use the software in any way that is against the law or to create or propagate malware; or |
||||
|
|
||||
|
**e)** share, publish, distribute, or lease the software (including as part of an application and except for any distributable code, subject to the terms above), provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party. |
||||
|
|
||||
|
## 5. DATA. |
||||
|
|
||||
|
**a) Data Collection.** The software may collect information about you and your use of the software, and send that to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may opt-out of many of these scenarios, but not all, as described in the product documentation. There are also some features in the software that may enable you to collect data from users of your applications. If you use these features to enable data collection in your applications, you must comply with applicable law, including providing appropriate notices to users of your applications. You can learn more about data collection and use in the help documentation and the privacy statement at <https://aka.ms/privacy>. Your use of the software operates as your consent to these practices. |
||||
|
|
||||
|
**b) Processing of Personal Data**. To the extent Microsoft is a processor or subprocessor of personal data in connection with the software, Microsoft makes the commitments in the European Union General Data Protection Regulation Terms of the Online Services Terms to all customers effective May 25, 2018, at <https://docs.microsoft.com/legal/gdpr>. |
||||
|
|
||||
|
## 6. EXPORT RESTRICTIONS. |
||||
|
You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit <https://aka.ms/exporting>. |
||||
|
|
||||
|
## 7. SUPPORT SERVICES. |
||||
|
Microsoft is not obligated under this agreement to provide any support services for the software. Any support provided is "as is", "with all faults", and without warranty of any kind. |
||||
|
|
||||
|
## 8. UPDATES. |
||||
|
The software may periodically check for updates, and download and install them for you. You may obtain updates only from Microsoft or authorized sources. Microsoft may need to update your system to provide you with updates. You agree to receive these automatic updates without any additional notice. Updates may not include or support all existing software features, services, or peripheral devices. |
||||
|
|
||||
|
## 9. BINDING ARBITRATION AND CLASS ACTION WAIVER. |
||||
|
This Section applies if you live in (or, if a business, your principal place of business is in) the United States.** If you and Microsoft have a dispute, you and Microsoft agree to try for 60 days to resolve it informally. If you and Microsoft can't, you and Microsoft **agree to binding individual arbitration before the American Arbitration Association under the Federal Arbitration Act ("FAA"), and not to sue in court in front of a judge or jury**. Instead, a neutral arbitrator will decide. **Class action lawsuits, class-wide arbitrations, private attorney-general actions, and any other proceeding where someone acts in a representative capacity are not allowed; nor is combining individual proceedings without the consent of all parties.** The complete Arbitration Agreement contains more terms and is at <https://aka.ms/arb-agreement-4>. You and Microsoft agree to these terms. |
||||
|
|
||||
|
## 10. TERMINATION. |
||||
|
Without prejudice to any other rights, Microsoft may terminate this agreement if you fail to comply with any of its terms or conditions. In such event, you must destroy all copies of the software and all of its component parts. |
||||
|
|
||||
|
## 11. ENTIRE AGREEMENT. |
||||
|
This agreement, and any other terms Microsoft may provide for supplements, updates, or third-party applications, is the entire agreement for the software. |
||||
|
|
||||
|
## 12. APPLICABLE LAW AND PLACE TO RESOLVE DISPUTES. |
||||
|
If you acquired the software in the United States or Canada, the laws of the state or province where you live (or, if a business, where your principal place of business is located) govern the interpretation of this agreement, claims for its breach, and all other claims (including consumer protection, unfair competition, and tort claims), regardless of conflict of laws principles, except that the FAA governs everything related to arbitration. If you acquired the software in any other country, its laws apply, except that the FAA governs everything related to arbitration. If U.S. federal jurisdiction exists, you and Microsoft consent to exclusive jurisdiction and venue in the federal court in King County, Washington for all disputes heard in court (excluding arbitration). If not, you and Microsoft consent to exclusive jurisdiction and venue in the Superior Court of King County, Washington for all disputes heard in court (excluding arbitration). |
||||
|
|
||||
|
## 13. CONSUMER RIGHTS; REGIONAL VARIATIONS. |
||||
|
This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state, province, or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state, province, or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you: |
||||
|
|
||||
|
**a) Australia.** You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights. |
||||
|
|
||||
|
**b) Canada.** If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software. |
||||
|
|
||||
|
**c) Germany and Austria**. |
||||
|
|
||||
|
**i. Warranty.** The properly licensed software will perform substantially as described in any Microsoft materials that accompany the software. However, Microsoft gives no contractual guarantee in relation to the licensed software. |
||||
|
**ii. Limitation of Liability.** In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as, in case of death or personal or physical injury, Microsoft is liable according to the statutory law. |
||||
|
|
||||
|
Subject to the foregoing clause ii., Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called \"cardinal obligations\"). In other cases of slight negligence, Microsoft will not be liable for slight negligence. |
||||
|
|
||||
|
## 14. DISCLAIMER OF WARRANTY. |
||||
|
THE SOFTWARE IS LICENSED "AS IS." YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. TO THE EXTENT PERMITTED UNDER APPLICABLE LAWS, MICROSOFT EXCLUDES ALL IMPLIED WARRANTIES, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.** |
||||
|
|
||||
|
## 15. LIMITATION ON AND EXCLUSION OF DAMAGES. |
||||
|
IF YOU HAVE ANY BASIS FOR RECOVERING DAMAGES DESPITE THE PRECEDING DISCLAIMER OF WARRANTY, YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. \$5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.** |
||||
|
|
||||
|
This limitation applies to (a) anything related to the software, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, warranty, guarantee, or condition; strict liability, negligence, or other tort; or any other claim; in each case to the extent permitted by applicable law. |
||||
|
|
||||
|
It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your state, province, or country may not allow the exclusion or limitation of incidental, consequential, or other damages. |
||||
|
|
||||
|
|
||||
|
**Please note: As this software is distributed in Canada, some of the clauses in this agreement are provided below in French. |
||||
|
**Remarque: Ce logiciel étant distribué au Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en français. |
||||
|
**EXONÉRATION DE GARANTIE. Le logiciel visé par une licence est offert « tel quel ». Toute utilisation de ce logiciel est à votre seule risque et péril. Microsoft n’accorde aucune autre garantie expresse. Vous pouvez bénéficier de droits additionnels en vertu du droit local sur la protection des consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualité marchande, d’adéquation à un usage particulier et d’absence de contrefaçon sont exclues. |
||||
|
**LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement à hauteur de 5,00 $ US. Vous ne pouvez prétendre à aucune indemnisation pour les autres dommages, y compris les dommages spéciaux, indirects ou accessoires et pertes de bénéfices. |
||||
|
**Cette limitation concerne: |
||||
|
** - tout ce qui est relié au logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers; et |
||||
|
** - les réclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilité stricte, de négligence ou d’une autre faute dans la limite autorisée par la loi en vigueur. |
||||
|
**Elle s’applique également, même si Microsoft connaissait ou devrait connaître l’éventualité d’un tel dommage. Si votre pays n’autorise pas l’exclusion ou la limitation de responsabilité pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l’exclusion ci-dessus ne s’appliquera pas à votre égard. |
||||
|
**EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous pourriez avoir d’autres droits prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois de votre pays si celles-ci ne le permettent pas. |
||||
@ -0,0 +1,53 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
|
<plist version="1.0"> |
||||
|
<dict> |
||||
|
<key>AvailableLibraries</key> |
||||
|
<array> |
||||
|
<dict> |
||||
|
<key>LibraryIdentifier</key> |
||||
|
<string>ios-arm64</string> |
||||
|
<key>LibraryPath</key> |
||||
|
<string>MicrosoftCognitiveServicesSpeech.framework</string> |
||||
|
<key>SupportedArchitectures</key> |
||||
|
<array> |
||||
|
<string>arm64</string> |
||||
|
</array> |
||||
|
<key>SupportedPlatform</key> |
||||
|
<string>ios</string> |
||||
|
</dict> |
||||
|
<dict> |
||||
|
<key>LibraryIdentifier</key> |
||||
|
<string>ios-arm64_x86_64-simulator</string> |
||||
|
<key>LibraryPath</key> |
||||
|
<string>MicrosoftCognitiveServicesSpeech.framework</string> |
||||
|
<key>SupportedArchitectures</key> |
||||
|
<array> |
||||
|
<string>arm64</string> |
||||
|
<string>x86_64</string> |
||||
|
</array> |
||||
|
<key>SupportedPlatform</key> |
||||
|
<string>ios</string> |
||||
|
<key>SupportedPlatformVariant</key> |
||||
|
<string>simulator</string> |
||||
|
</dict> |
||||
|
<dict> |
||||
|
<key>LibraryIdentifier</key> |
||||
|
<string>macos-arm64_x86_64</string> |
||||
|
<key>LibraryPath</key> |
||||
|
<string>MicrosoftCognitiveServicesSpeech.framework</string> |
||||
|
<key>SupportedArchitectures</key> |
||||
|
<array> |
||||
|
<string>arm64</string> |
||||
|
<string>x86_64</string> |
||||
|
</array> |
||||
|
<key>SupportedPlatform</key> |
||||
|
<string>macos</string> |
||||
|
</dict> |
||||
|
</array> |
||||
|
<key>CFBundlePackageType</key> |
||||
|
<string>XFWK</string> |
||||
|
<key>XCFrameworkFormatVersion</key> |
||||
|
<string>1.0</string> |
||||
|
</dict> |
||||
|
</plist> |
||||
@ -0,0 +1,201 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXAudioStream.h" |
||||
|
#import "SPXAudioProcessingOptions.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents audio input or output configuration. Audio input can be from a microphone, file, or input stream. |
||||
|
* Audio output can be to a speaker, audio file output in WAV format, or output stream. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXAudioConfiguration : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the default microphone on the system. |
||||
|
* |
||||
|
* @return an instance of audio input configuration. |
||||
|
*/ |
||||
|
- (nonnull instancetype)init; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the default microphone on the system and audio processing options. |
||||
|
* |
||||
|
* @param audioProcessingOptions the audio processing options. |
||||
|
* @return an instance of audio input configuration. |
||||
|
*/ |
||||
|
- (nonnull instancetype)init:(nonnull SPXAudioProcessingOptions *)audioProcessingOptions; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the specified audio input of the system. |
||||
|
* |
||||
|
* Added in version 1.3.0. |
||||
|
* |
||||
|
* @param deviceName the unique ID of the input device to be used. If this is nil, the default is used. Please refer to <a href="https://aka.ms/csspeech/microphone-selection">this page</a> on how to retrieve platform-specific microphone names. |
||||
|
* @note Specifying a non-default device name is not supported in iOS. |
||||
|
* @note If the specified device is not available, a failure will occur when starting recognition using this SPXAudioConfiguration object. |
||||
|
* @return an instance of audio input configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithMicrophone:(nullable NSString *)deviceName; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the specified audio input of the system and audio processing options. |
||||
|
* |
||||
|
* @param deviceName the unique ID of the input device to be used. If this is nil, the default is used. Please refer to <a href="https://aka.ms/csspeech/microphone-selection">this page</a> on how to retrieve platform-specific microphone names. |
||||
|
* @param audioProcessingOptions the audio processing options. |
||||
|
* @note Specifying a non-default device name is not supported in iOS. |
||||
|
* @note If the specified device is not available, a failure will occur when starting recognition using this SPXAudioConfiguration object. |
||||
|
* @return an instance of audio input configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithMicrophone:(nullable NSString *)deviceName audioProcessingOptions:(nonnull SPXAudioProcessingOptions *)audioProcessingOptions; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the specified file as input. |
||||
|
* |
||||
|
* @param path path of the audio input file. |
||||
|
* @return an instance of audio input configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithWavFileInput:(nonnull NSString *)path; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the specified file as input and audio processing options. |
||||
|
* |
||||
|
* @param path path of the audio input file. |
||||
|
* @param audioProcessingOptions the audio processing options. |
||||
|
* @return an instance of audio input configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithWavFileInput:(nonnull NSString *)path audioProcessingOptions:(nonnull SPXAudioProcessingOptions *)audioProcessingOptions; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the default audio output device (speaker) on the system as output. |
||||
|
* @note Please ensure that the speaker is available before using this method. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
* |
||||
|
* @return an instance of audio input configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithDefaultSpeakerOutput |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the default audio output device (speaker) on the system as output. |
||||
|
* @note Please ensure that the speaker is available before using this method. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return an instance of audio input configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithDefaultSpeakerOutput:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using a given audio output device (speaker) on the system as output. |
||||
|
* @param deviceName the unique ID of the input device to be used. |
||||
|
* @return an instance of audio input configuration. |
||||
|
* @note Specifying a non-default device name is not supported in iOS. |
||||
|
* @note Please ensure that the speaker is available before using this method. |
||||
|
* |
||||
|
* Added in version 1.17.0 |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeakerOutput:(nonnull NSString *)deviceName |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using a given audio output device (speaker) on the system as output. |
||||
|
* @param deviceName the unique ID of the input device to be used. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of audio input configuration. |
||||
|
* @note Specifying a non-default device name is not supported in iOS. |
||||
|
* @note Please ensure that the speaker is available before using this method. |
||||
|
* |
||||
|
* Added in version 1.17.0 |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeakerOutput:(nonnull NSString *)deviceName error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the specified file as output. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
* |
||||
|
* @param path path of the audio output file. The parent directory must already exist. |
||||
|
* @return an instance of audio input configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithWavFileOutput:(nonnull NSString *)path |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the specified file as output. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
* |
||||
|
* @param path path of the audio output file. The parent directory must already exist. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of audio input configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithWavFileOutput:(nonnull NSString *)path error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the specified stream as input. |
||||
|
* |
||||
|
* @param stream the custom audio input stream. |
||||
|
* @return an instance of audio input configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithStreamInput:(nonnull SPXAudioInputStream *)stream; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the specified stream as input. |
||||
|
* |
||||
|
* @param stream the custom audio input stream. |
||||
|
* @param audioProcessingOptions the audio processing options. |
||||
|
* @return an instance of audio input configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithStreamInput:(nonnull SPXAudioInputStream *)stream audioProcessingOptions:(nonnull SPXAudioProcessingOptions *)audioProcessingOptions; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the specified stream as output. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
* |
||||
|
* @param stream the custom audio output stream. |
||||
|
* @return an instance of audio output configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithStreamOutput:(nonnull SPXAudioOutputStream *)stream |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioConfiguration object using the specified stream as output. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
* |
||||
|
* @param stream the custom audio output stream. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of audio output configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithStreamOutput:(nonnull SPXAudioOutputStream *)stream error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the property value. |
||||
|
* If the name is not available, it returns an empty string. |
||||
|
* |
||||
|
* @param name property name. |
||||
|
* @return value of the property. |
||||
|
*/ |
||||
|
-(nullable NSString *)getPropertyByName:(nonnull NSString *)name; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the property value by name. |
||||
|
* |
||||
|
* @param name property name. |
||||
|
* @param value value of the property. |
||||
|
*/ |
||||
|
-(void)setPropertyTo:(nonnull NSString *)value byName:(nonnull NSString *)name; |
||||
|
|
||||
|
/**
|
||||
|
* The audio processing options. |
||||
|
*/ |
||||
|
@property (readonly, nullable)SPXAudioProcessingOptions *audioProcessingOptions; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,133 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
#import "SPXSpeechSynthesisResult.h" |
||||
|
#import "SPXKeywordRecognitionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents audio data stream used for operating audio data as a stream. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXAudioDataStream : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an audio data stream from given speech synthesis result. |
||||
|
* |
||||
|
* @param result the speech synthesis result. |
||||
|
* @return an instance of audio data stream. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromSynthesisResult:(nonnull SPXSpeechSynthesisResult *)result |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an audio data stream from given speech synthesis result. |
||||
|
* |
||||
|
* @param result the speech synthesis result. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of audio data stream. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromSynthesisResult:(nonnull SPXSpeechSynthesisResult *)result error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Obtains the memory backed AudioDataStream associated with a given KeywordRecognition result. |
||||
|
* |
||||
|
* @param result the keyword recognition result. |
||||
|
* @return An audio stream with the input to the KeywordRecognizer starting from right before the Keyword. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromKeywordRecognitionResult:(nonnull SPXKeywordRecognitionResult *)result |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Obtains the memory backed AudioDataStream associated with a given KeywordRecognition result. |
||||
|
* |
||||
|
* @param result the keyword recognition result. |
||||
|
* @param outError error information. |
||||
|
* @return An audio stream with the input to the KeywordRecognizer starting from right before the Keyword. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromKeywordRecognitionResult:(nonnull SPXKeywordRecognitionResult *)result error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Get current status of the audio data stream. |
||||
|
* |
||||
|
* @return current status. |
||||
|
*/ |
||||
|
- (SPXStreamStatus)getStatus; |
||||
|
|
||||
|
/**
|
||||
|
* Check wheather the stream has enough data to be read. |
||||
|
* |
||||
|
* @param bytesRequested the request data size in bytes. |
||||
|
* @return a bool indicating whether the stream has enough data to be read. |
||||
|
*/ |
||||
|
- (BOOL)canReadData:(NSUInteger)bytesRequested; |
||||
|
|
||||
|
/**
|
||||
|
* Check whether the stream has enough data to be read, starting from the specified position. |
||||
|
* |
||||
|
* @param pos the position counting from start of the stream. |
||||
|
* @param bytesRequested the request data size in bytes. |
||||
|
* @return a bool indicating whether the stream has enough data to be read. |
||||
|
*/ |
||||
|
- (BOOL)canReadDataFromPosition:(NSUInteger)pos bytesRequested:(NSUInteger)bytesRequested; |
||||
|
|
||||
|
/**
|
||||
|
* Reads a chunk of the audio data and fill it to given buffer. |
||||
|
* |
||||
|
* @param data a buffer to receive read data. |
||||
|
* @param length length of the data to be received. |
||||
|
* @return length of data filled to the buffer, 0 means end of stream. |
||||
|
*/ |
||||
|
- (NSUInteger)readData:(nonnull NSMutableData *)data length:(NSUInteger)length; |
||||
|
|
||||
|
/**
|
||||
|
* Reads a chunk of the audio data and fill it to given buffer, starting from the specified position. |
||||
|
* |
||||
|
* @param pos the position counting from start of the stream. |
||||
|
* @param data a buffer to receive read data. |
||||
|
* @param length length of the data to be received. |
||||
|
* @return length of data filled to the buffer, 0 means end of stream. |
||||
|
*/ |
||||
|
- (NSUInteger)readDataFromPosition:(NSUInteger)pos data:(nonnull NSMutableData *)data length:(NSUInteger)length; |
||||
|
|
||||
|
/**
|
||||
|
* Save the audio data to a file. |
||||
|
* |
||||
|
* @param fileName the file name with full path. |
||||
|
*/ |
||||
|
- (void)saveToWavFile:(nonnull NSString *)fileName; |
||||
|
|
||||
|
/**
|
||||
|
* Get current position of the audio data stream. |
||||
|
* |
||||
|
* @return current position |
||||
|
*/ |
||||
|
- (NSUInteger)getPosition; |
||||
|
|
||||
|
/**
|
||||
|
* Set current position of the audio data stream. |
||||
|
* |
||||
|
* @param pos position to be set. |
||||
|
*/ |
||||
|
- (void)setPosition:(NSUInteger)pos; |
||||
|
|
||||
|
/**
|
||||
|
* Stops any more data from getting to the stream. |
||||
|
* |
||||
|
*/ |
||||
|
- (void)detachInput |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops any more data from getting to the stream. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (void)detachInput:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,43 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license201809 for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#include "SPXFoundation.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents audio processing constants used for specifying the processing in AudioProcessingOptions. |
||||
|
*/ |
||||
|
typedef NS_OPTIONS(NSUInteger, SPXAudioProcessingConstants) |
||||
|
{ |
||||
|
/**
|
||||
|
* Disables built-in input audio processing. |
||||
|
*/ |
||||
|
SPX_AUDIO_INPUT_PROCESSING_NONE = 0x00000000, |
||||
|
/**
|
||||
|
* Enable voice activity detection in input audio processing. |
||||
|
*/ |
||||
|
SPX_AUDIO_INPUT_PROCESSING_ENABLE_VOICE_ACTIVITY_DETECTION = 0x00000020 |
||||
|
}; |
||||
|
|
||||
|
/**
|
||||
|
* Represents audio processing options used with audio config class. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXAudioProcessingOptions : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAudioProcessingOptions object using audio processing flags. |
||||
|
* |
||||
|
* @param audioProcessingFlags the flags to control the audio processing performed by Speech SDK. It is bitwise OR of SPX_AUDIO_INPUT_PROCESSING_XXX constants from SPXAudioProcessingConstants enum. |
||||
|
* @return an instance of audio processing options. |
||||
|
*/ |
||||
|
- (nonnull instancetype)init:(SPXAudioProcessingConstants)audioProcessingFlags; |
||||
|
|
||||
|
/**
|
||||
|
* The type of audio processing performed by Speech SDK. |
||||
|
* Bitwise OR of SPX_AUDIO_INPUT_PROCESSING_XXX constant flags from SPXAudioProcessingConstants enum indicating the input audio processing performed by Speech SDK. |
||||
|
*/ |
||||
|
@property (readonly)SPXAudioProcessingConstants audioProcessingFlags; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,168 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXAudioStreamFormat.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
|
||||
|
typedef NSInteger (^SPXPullAudioInputStreamReadHandler)(NSMutableData * _Nonnull, NSUInteger); |
||||
|
typedef void (^SPXPullAudioInputStreamCloseHandler)(void); |
||||
|
typedef NSString * _Nonnull (^SPXPullAudioInputStreamGetPropertyHandler)(SPXPropertyId); |
||||
|
|
||||
|
typedef NSUInteger (^SPXPushAudioOutputStreamWriteHandler)(NSData * _Nonnull); |
||||
|
typedef void (^SPXPushAudioOutputStreamCloseHandler)(void); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Base class representing the audio input stream used for custom audio input configurations. |
||||
|
* Currently no property and methods defined in the base class. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXAudioInputStream : NSObject |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Represents memory backed push audio input stream used for custom audio input configurations. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXPushAudioInputStream : SPXAudioInputStream |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a memory-backed SPXPushAudioInputStream using the default format (16 kHz, 16 bit, mono PCM). |
||||
|
* @return an instance of push audio input stream. |
||||
|
*/ |
||||
|
- (nonnull instancetype)init; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a memory-backed SPXPushAudioInputStream with the specified audio format. |
||||
|
* |
||||
|
* @param format The audio data format in which audio will be written to the push audio stream's write() method. |
||||
|
* @return an instance of push audio input stream. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAudioFormat:(nonnull SPXAudioStreamFormat *)format; |
||||
|
|
||||
|
/**
|
||||
|
* Writes the specified audio data by making an internal copy of the data. |
||||
|
* Note: The data should not contain any audio header. |
||||
|
* |
||||
|
* @param data The audio buffer of which this function will make a copy. |
||||
|
*/ |
||||
|
- (void)write:(nonnull NSData *)data; |
||||
|
|
||||
|
/**
|
||||
|
* Closes the stream. |
||||
|
*/ |
||||
|
- (void)close; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Represents an audio input stream used for custom audio input configurations. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXPullAudioInputStream : SPXAudioInputStream |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXPullAudioInputStream that delegates to the specified callback interface for read() and close() methods, using the default format (16 kHz, 16 bit, mono PCM). |
||||
|
* |
||||
|
* @param readHandler handler which will be called in order to read data from the audio input stream. If no data is currently available in the stream, the readHandler should wait until data is available. It returns the number of bytes that have been read. It returns 0 when the stream should be closed. The data returned by read() should not contain any audio header. |
||||
|
* @param closeHandler handler which will be called in order to close the audio input stream. |
||||
|
* @return an instance of pull audio input stream. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithReadHandler:(nonnull SPXPullAudioInputStreamReadHandler)readHandler closeHandler:(nonnull SPXPullAudioInputStreamCloseHandler)closeHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXPullAudioInputStream that delegates to the specified callback functions for read() and close() methods, with the specified audio format. |
||||
|
* |
||||
|
* @param format The audio data format in which audio will be written to the push audio stream's write() method. |
||||
|
* @param readHandler handler which will be called in order to read data from the audio input stream. If no data is currently available in the stream, the readHandler should wait until data is available. It returns the number of bytes that have been read. It returns 0 when stream should be closed. The data returned by read() should not contain any audio header. |
||||
|
* @param closeHandler handler which will be called in order to close the audio input stream. |
||||
|
* @return The audio input stream being created. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAudioFormat:(nonnull SPXAudioStreamFormat *)format readHandler:(nonnull SPXPullAudioInputStreamReadHandler)readHandler closeHandler:(nonnull SPXPullAudioInputStreamCloseHandler)closeHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXPullAudioInputStream that delegates to the specified callback interface for read() and close() methods, using the default format (16 kHz, 16 bit, mono PCM). |
||||
|
* |
||||
|
* @param readHandler handler which will be called in order to read data from the audio input stream. If no data is currently available in the stream, the readHandler should wait until data is available. It returns the number of bytes that have been read. It returns 0 when the stream should be closed. The data returned by read() should not contain any audio header. |
||||
|
* @param getPropertyHandler handler which will be called in order to get string information associated to given SPXPropertyId. |
||||
|
* @param closeHandler handler which will be called in order to close the audio input stream. |
||||
|
* @return an instance of pull audio input stream. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithReadHandler:(nonnull SPXPullAudioInputStreamReadHandler)readHandler getPropertyHandler:(nonnull SPXPullAudioInputStreamGetPropertyHandler)getPropertyHandler closeHandler:(nonnull SPXPullAudioInputStreamCloseHandler)closeHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXPullAudioInputStream that delegates to the specified callback functions for read() and close() methods, with the specified audio format. |
||||
|
* |
||||
|
* @param format The audio data format in which audio will be written to the push audio stream's write() method. |
||||
|
* @param readHandler handler which will be called in order to read data from the audio input stream. If no data is currently available in the stream, the readHandler should wait until data is available. It returns the number of bytes that have been read. It returns 0 when stream should be closed. The data returned by read() should not contain any audio header. |
||||
|
* @param getPropertyHandler handler which will be called in order to get string information associated to given SPXPropertyId. |
||||
|
* @param closeHandler handler which will be called in order to close the audio input stream. |
||||
|
* @return The audio input stream being created. |
||||
|
*/ |
||||
|
|
||||
|
- (nullable instancetype)initWithAudioFormat:(nonnull SPXAudioStreamFormat *)format readHandler:(nonnull SPXPullAudioInputStreamReadHandler)readHandler |
||||
|
getPropertyHandler:(nonnull SPXPullAudioInputStreamGetPropertyHandler)getPropertyHandler |
||||
|
closeHandler:(nonnull SPXPullAudioInputStreamCloseHandler)closeHandler; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Base class representing the audio output stream used for custom audio output configurations. |
||||
|
* Currently no property and methods defined in the base class. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXAudioOutputStream : NSObject |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Represents memory backed pull audio output stream used for custom audio output. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXPullAudioOutputStream : SPXAudioOutputStream |
||||
|
|
||||
|
/**
|
||||
|
* Creates a memory backed PullAudioOutputStream with the specified audio format. |
||||
|
* |
||||
|
* @return An instance of pull audio output stream |
||||
|
*/ |
||||
|
- (nonnull instancetype)init; |
||||
|
|
||||
|
/**
|
||||
|
* Reads a chunk of the audio data and fill it to given buffer |
||||
|
* |
||||
|
* @param data a buffer to receive read data. |
||||
|
* @param length the length of data to receive. |
||||
|
* @return size of data filled to the buffer, 0 means end of stream |
||||
|
*/ |
||||
|
- (NSUInteger)read:(nonnull NSMutableData *)data length:(NSUInteger) length; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Represents a push audio output stream used for custom audio output configurations. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXPushAudioOutputStream : SPXAudioOutputStream |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXPushAudioOutputStream that delegates to the specified callback interface for write() and close() methods. |
||||
|
* |
||||
|
* @param writeHandler Handler which will be called in order to write data synchronously to the data stream. |
||||
|
* @param closeHandler Handler which will be called to close the audio stream. |
||||
|
* |
||||
|
* @return an instance of push audio output stream. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithWriteHandler:(nonnull SPXPushAudioOutputStreamWriteHandler)writeHandler closeHandler:(nonnull SPXPushAudioOutputStreamCloseHandler)closeHandler; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,90 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXAudioStreamFormat.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines supported audio stream container format. |
||||
|
* Added in version 1.7.0. |
||||
|
* Note: Compressed input is only supported on iOS. |
||||
|
*/ |
||||
|
typedef NS_ENUM(NSUInteger, SPXAudioStreamContainerFormat) |
||||
|
{ |
||||
|
/**
|
||||
|
* Stream ContainerFormat definition for OGG OPUS. |
||||
|
*/ |
||||
|
SPXAudioStreamContainerFormat_OGG_OPUS = 0x101, |
||||
|
|
||||
|
/**
|
||||
|
* Stream ContainerFormat definition for MP3. |
||||
|
*/ |
||||
|
SPXAudioStreamContainerFormat_MP3 = 0x102, |
||||
|
|
||||
|
/**
|
||||
|
* Stream ContainerFormat definition for FLAC. Added in version 1.7.0. |
||||
|
*/ |
||||
|
SPXAudioStreamContainerFormat_FLAC = 0x103, |
||||
|
|
||||
|
/**
|
||||
|
* Stream ContainerFormat definition for ALAW. Added in version 1.7.0. |
||||
|
*/ |
||||
|
SPXAudioStreamContainerFormat_ALAW = 0x104, |
||||
|
|
||||
|
/**
|
||||
|
* Stream ContainerFormat definition for MULAW. Added in version 1.7.0. |
||||
|
*/ |
||||
|
SPXAudioStreamContainerFormat_MULAW = 0x105, |
||||
|
|
||||
|
/**
|
||||
|
* Stream ContainerFormat definition for AMRNB. Currently not supported. |
||||
|
*/ |
||||
|
SPXAudioStreamContainerFormat_AMRNB = 0x106, |
||||
|
|
||||
|
/**
|
||||
|
* Stream ContainerFormat definition for AMRWB. Currently not supported. |
||||
|
*/ |
||||
|
SPXAudioStreamContainerFormat_AMRWB = 0x107, |
||||
|
|
||||
|
/**
|
||||
|
* Stream ContainerFormat definition for any other or unknown format. |
||||
|
*/ |
||||
|
SPXAudioStreamContainerFormat_ANY = 0x108 |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
/**
|
||||
|
* Represents the audio stream format used for custom audio input configurations. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXAudioStreamFormat : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Initializes the audio stream format object with the default audio stream format (16 kHz, 16 bit, mono PCM). |
||||
|
* |
||||
|
* @return an instance of audio stream format. |
||||
|
*/ |
||||
|
- (nonnull instancetype)init; |
||||
|
|
||||
|
/**
|
||||
|
* Initialize the audio stream format object with the specified PCM waveformat characteristics. |
||||
|
* |
||||
|
* @param samplesPerSecond sample rate, in samples per second (Hertz). |
||||
|
* @param bitsPerSample bits per sample. |
||||
|
* @param channels number of channels in the waveform-audio data. |
||||
|
* @return an instance of audio stream format. |
||||
|
*/ |
||||
|
- (nullable instancetype)initUsingPCMWithSampleRate:(NSUInteger)samplesPerSecond bitsPerSample:(NSUInteger)bitsPerSample channels:(NSUInteger)channels; |
||||
|
|
||||
|
/**
|
||||
|
* Creates an audio stream format object with the specified compressed audio container format, to be used as input format. |
||||
|
* Support added in 1.5.0. |
||||
|
* Note: Compressed input is only supported on iOS. |
||||
|
* @param audioStreamContainerFormat compressed format type. |
||||
|
* @return an instance of audio stream format. |
||||
|
*/ |
||||
|
- (nullable instancetype)initUsingCompressedFormat:(SPXAudioStreamContainerFormat)audioStreamContainerFormat; |
||||
|
@end |
||||
|
|
||||
@ -0,0 +1,84 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSourceLanguageConfiguration.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents auto detection source language configuration |
||||
|
* Updated in version 1.13.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXAutoDetectSourceLanguageConfiguration : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAutoDetectSourceLanguageConfiguration object with open range. |
||||
|
* |
||||
|
* Note: only SPXSpeechSynthesizer and multilingual SPXTranslationRecognizer support source language auto detection from open range, |
||||
|
* for SPXRecognizer, please use SPXAutoDetectSourceLanguageConfig with specific source languages. |
||||
|
* |
||||
|
* Added in version 1.13.0 |
||||
|
* |
||||
|
* @return an instance of auto detection source language configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithOpenRange |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAutoDetectSourceLanguageConfiguration object with open range |
||||
|
* |
||||
|
* Note: only SPXSpeechSynthesizer and multilingual SPXTranslationRecognizer support source language auto detection from open range, |
||||
|
* for SPXRecognizer, please use SPXAutoDetectSourceLanguageConfig with specific source languages. |
||||
|
* |
||||
|
* Added in version 1.13.0 |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* |
||||
|
* @return an instance of auto detection source language configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithOpenRange:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAutoDetectSourceLanguageConfiguration object using languages. |
||||
|
* |
||||
|
* @param languages the candidate languages. |
||||
|
* |
||||
|
* @return an instance of auto detection source language configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull NSArray<NSString *> *)languages |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAutoDetectSourceLanguageConfiguration object using languages. |
||||
|
* |
||||
|
* @param languages the candidate languages. |
||||
|
* @param outError error information. |
||||
|
* |
||||
|
* @return an instance of auto detection source language configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull NSArray<NSString *> *)languages error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAutoDetectSourceLanguageConfiguration object using source language configurations. |
||||
|
* |
||||
|
* @param sourceLanguageConfigurations the candidate source languages' configurations. |
||||
|
* |
||||
|
* @return an instance of auto detection source language configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSourceLanguageConfigurations:(nonnull NSArray<SPXSourceLanguageConfiguration *> *)sourceLanguageConfigurations |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAutoDetectSourceLanguageConfiguration object using source language configurations. |
||||
|
* |
||||
|
* @param sourceLanguageConfigurations the candidate source languages' configurations. |
||||
|
* @param outError error information. |
||||
|
* |
||||
|
* @return an instance of auto detection source language configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSourceLanguageConfigurations:(nonnull NSArray<SPXSourceLanguageConfiguration *> *)sourceLanguageConfigurations |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,32 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechRecognitionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents auto detection source language result |
||||
|
* Added in version 1.12.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXAutoDetectSourceLanguageResult : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The language result. It is empty if the service cannot detect the language. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *language; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXAutoDetectSourceLanguageResult object using SPXSpeechRecognitionResult. |
||||
|
* |
||||
|
* @param speechRecognitionResult the speech recognition result |
||||
|
* |
||||
|
* @return an instance of auto detection source language result. |
||||
|
*/ |
||||
|
|
||||
|
- (nonnull instancetype)init:(nonnull SPXRecognitionResult *)speechRecognitionResult; |
||||
|
|
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,201 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognizer.h" |
||||
|
#import "SPXConversationTranslator.h" |
||||
|
#import "SPXSpeechSynthesizer.h" |
||||
|
#import "SPXDialogServiceConnector.h" |
||||
|
#import "SPXConnectionEventArgs.h" |
||||
|
#import "SPXConnectionMessageEventArgs.h" |
||||
|
|
||||
|
/**
|
||||
|
* Connection is a proxy class for managing connection to the speech service of the specified Recognizer. |
||||
|
* By default, a Recognizer autonomously manages connection to service when needed. |
||||
|
* The Connection class provides additional methods for users to explicitly open or close a connection and |
||||
|
* to subscribe to connection status changes. |
||||
|
* The use of Connection is optional. It is intended for scenarios where fine tuning of application |
||||
|
* behavior based on connection status is needed. Users can optionally call Open() to manually |
||||
|
* initiate a service connection before starting recognition on the Recognizer associated with this Connection. |
||||
|
* After starting a recognition, calling Open() or Close() might fail. This will not impact |
||||
|
* the Recognizer or the ongoing recognition. Connection might drop for various reasons, the Recognizer will |
||||
|
* always try to reinstitute the connection as required to guarantee ongoing operations. In all these cases |
||||
|
* Connected/Disconnected events will indicate the change of the connection status. |
||||
|
* |
||||
|
* Added in version 1.2.0. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConnection : NSObject |
||||
|
|
||||
|
typedef void (^SPXConnectionEventHandler)(SPXConnection* _Nonnull, SPXConnectionEventArgs * _Nonnull); |
||||
|
typedef void (^SPXConnectionMessageEventHandler)(SPXConnection* _Nonnull, SPXConnectionMessageEventArgs * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* Gets the Connection instance from the specified recognizer. |
||||
|
* |
||||
|
* @param recognizer The recognizer associated with the connection. |
||||
|
* @return The Connection instance of the recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromRecognizer:(nonnull SPXRecognizer *)recognizer |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Gets the Connection instance from the specified recognizer. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param recognizer The recognizer associated with the connection. |
||||
|
* @return The Connection instance of the recognizer. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromRecognizer:(nonnull SPXRecognizer *)recognizer error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Gets the Connection instance from the specified conversation translator. |
||||
|
* |
||||
|
* @param translator The conversation translator associated with the connection. |
||||
|
* @return The Connection instance of the conversation translator. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromConversationTranslator:(nonnull SPXConversationTranslator *)translator |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Gets the Connection instance from the specified conversation translator. |
||||
|
* |
||||
|
* Added in version 1.13.0. |
||||
|
* |
||||
|
* @param translator The conversation translator associated with the connection. |
||||
|
* @return The Connection instance of the conversation translator. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromConversationTranslator:(nonnull SPXConversationTranslator *)translator error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Gets the Connection instance from the specified speech synthesizer. |
||||
|
* |
||||
|
* Added in version 1.17.0 |
||||
|
* |
||||
|
* @param synthesizer The speech synthesizer associated with the connection. |
||||
|
* @return The Connection instance of the speech synthesizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromSpeechSynthesizer:(nonnull SPXSpeechSynthesizer *)synthesizer |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Gets the Connection instance from the specified speech synthesizer. |
||||
|
* |
||||
|
* Added in version 1.17.0 |
||||
|
* |
||||
|
* @param synthesizer The speech synthesizer associated with the connection. |
||||
|
* @return The Connection instance of the speech synthesizer. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromSpeechSynthesizer:(nonnull SPXSpeechSynthesizer *)synthesizer error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a Connection instance from the specified DialogServiceConnector. |
||||
|
* |
||||
|
* @param dialogServiceConnector the DialogServiceConnector instance associated with the connection. |
||||
|
* @return a Connection instance associated with the provided DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nonnull instancetype)initFromDialogServiceConnector:(nonnull SPXDialogServiceConnector *)dialogServiceConnector |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a Connection instance from the specified DialogServiceConnector. |
||||
|
* |
||||
|
* @param dialogServiceConnector the DialogServiceConnector instance associated with the connection. |
||||
|
* @param outError error information. |
||||
|
* @return a Connection instance associated with the provided DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromDialogServiceConnector:(nonnull SPXDialogServiceConnector *)dialogServiceConnector error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Starts to set up connection to the service. |
||||
|
* Users can optionally call Open() to manually set up a connection in advance before starting recognition on the |
||||
|
* Recognizer associated with this Connection. After starting recognition, calling Open() might fail, depending on |
||||
|
* the process state of the Recognizer. But the failure does not affect the state of the associated Recognizer. |
||||
|
* |
||||
|
* Note: On return, the connection might not be ready yet. Please subscribe to the Connected event to |
||||
|
* be notified when the connection is established. |
||||
|
* |
||||
|
* @param forContinuousRecognition indicates whether the connection is used for continuous recognition or single-shot recognition. |
||||
|
*/ |
||||
|
- (void)open:(BOOL)forContinuousRecognition; |
||||
|
|
||||
|
/**
|
||||
|
* Closes the connection the service. |
||||
|
* Users can optionally call Close() to manually shutdown the connection of the associated Recognizer. The call |
||||
|
* might fail, depending on the process state of the Recognizer. But the failure does not affect the state of the |
||||
|
* associated Recognizer. |
||||
|
*/ |
||||
|
- (void)close; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Connected event which indicates that the recognizer is connected to service. |
||||
|
* In order to receive the Connected event after subscribing to it, the Connection object itself needs to be alive. |
||||
|
* If the Connection object owning this event is out of its life time, all subscribed events won't be delivered. |
||||
|
*/ |
||||
|
- (void)addConnectedEventHandler:(nonnull SPXConnectionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribe to the Disconnected event which indicates that the recognizer is disconnected from service. |
||||
|
* In order to receive the Disconnected event after subscribing to it, the Connection object itself needs to be alive. |
||||
|
* If the Connection object owning this event is out of its life time, all subscribed events won't be delivered. |
||||
|
*/ |
||||
|
- (void)addDisconnectedEventHandler:(nonnull SPXConnectionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the ConnectionMessageReceived event which indicates that a message is received from the service. |
||||
|
* In order to receive the ConnectionMessageReceived event after subscribing to it, the Connection object itself |
||||
|
* needs to be alive. If the Connection object owning this event is out of its life time, all subscribed events |
||||
|
* won't be delivered. |
||||
|
*/ |
||||
|
- (void)addMessageReceivedEventHandler:(nonnull SPXConnectionMessageEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Appends a parameter in a message to service. |
||||
|
* Added in version 1.9.0. |
||||
|
* |
||||
|
* @param path The path of the message. |
||||
|
* @param propertyName The propertyName of the message. |
||||
|
* @param propertyValue The propertyValue of the message as a json string. |
||||
|
*/ |
||||
|
- (void)setMessageProperty:(nonnull NSString *)path propertyName:(nonnull NSString *)propertyName propertyValue:(nonnull NSString *)propertyValue |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Appends a parameter in a message to service. |
||||
|
* Added in version 1.17.0. |
||||
|
* |
||||
|
* @param path The path of the message. |
||||
|
* @param propertyName The propertyName of the message. |
||||
|
* @param propertyValue The propertyValue of the message as a json string. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)setMessageProperty:(nonnull NSString *)path propertyName:(nonnull NSString *)propertyName propertyValue:(nonnull NSString *)propertyValue error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Send message to service. |
||||
|
* Added in version 1.9.0. |
||||
|
* |
||||
|
* @param path The path of the message. |
||||
|
* @param payload The payload of the message as a json string. |
||||
|
*/ |
||||
|
- (void)sendMessage:(nonnull NSString *)path payload:(nonnull NSString *)payload |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Send message to service. |
||||
|
* Added in version 1.9.0. |
||||
|
* |
||||
|
* @param path The path of the message. |
||||
|
* @param payload The payload of the message as a json string. |
||||
|
* @return The boolean value indicating successful operation. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)sendMessage:(nonnull NSString *)path payload:(nonnull NSString *)payload error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,17 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSessionEventArgs.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload for Connected/Disconnected events. |
||||
|
* |
||||
|
* Added in version 1.2.0. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConnectionEventArgs : SPXSessionEventArgs |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,51 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
|
||||
|
/**
|
||||
|
* ConnectionMessage represents implementation specific messages sent to and received from |
||||
|
* the speech service. These messages are provided for debugging purposes and should not |
||||
|
* be used for production use cases with the Azure Cognitive Services Speech Service. |
||||
|
* Messages sent to and received from the Speech Service are subject to change without |
||||
|
* notice. This includes message contents, headers, payloads, ordering, etc. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConnectionMessage : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Gets the path associated with SPXConnectionMessage. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *path; |
||||
|
|
||||
|
/**
|
||||
|
* Checks to see if the ConnectionMessage is a text message. |
||||
|
*/ |
||||
|
@property (readonly)bool isTextMessage; |
||||
|
|
||||
|
/**
|
||||
|
* Checks to see if the ConnectionMessage is a binary message. |
||||
|
*/ |
||||
|
@property (readonly)bool isBinaryMessage; |
||||
|
|
||||
|
/**
|
||||
|
* Gets the text message payload. Typically the text message content-type is |
||||
|
* application/json. To determine other content-types use Properties.GetProperty("Content-Type"). |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *textMessage; |
||||
|
|
||||
|
/**
|
||||
|
* Gets the binary message payload. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSData *binaryMessage; |
||||
|
|
||||
|
/**
|
||||
|
* Gets the collection of properties and their values defined for SPXConnectionMessage. |
||||
|
* Message headers can be accessed via this collection (e.g. "Content-Type"). |
||||
|
*/ |
||||
|
@property (readonly, nullable)id <SPXPropertyCollection> properties; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,21 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXConnectionMessage.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload for Connection's message events. |
||||
|
* |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConnectionMessageEventArgs : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The SPXConnectionMessage instance associated with SPXConnectionMessageEventArgs. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)SPXConnectionMessage *message; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,338 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXUser.h" |
||||
|
#import "SPXParticipant.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
#import "SPXSpeechConfiguration.h" |
||||
|
|
||||
|
/**
|
||||
|
* Performs conversation management including add and remove participants. |
||||
|
* |
||||
|
* Added in version 1.13.0. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConversation : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The collection of properties and their values defined for this SPXConversation. |
||||
|
*/ |
||||
|
@property (readonly, nullable)id <SPXPropertyCollection> properties; |
||||
|
|
||||
|
/**
|
||||
|
* The unique identifier for the conversation. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *conversationId; |
||||
|
|
||||
|
/**
|
||||
|
* The authorization token used to communicate with the service. |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, |
||||
|
* the caller needs to refresh it by calling this setter with a new valid token. Otherwise, the recognizer will |
||||
|
* encounter errors during recognition. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *authorizationToken; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation using the specified speech configuration. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration. |
||||
|
* @return a conversation instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation using the specified speech configuration. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration. |
||||
|
* @param outError error information. |
||||
|
* @return a conversation instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation using the specified speech configuration and conversation id. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration. |
||||
|
* @param conversationId a unqiue identification of your conversation. |
||||
|
* @return a conversation instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration conversationId:(nonnull NSString *)conversationId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation using the specified speech configuration and conversation id. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration. |
||||
|
* @param conversationId a unqiue identification of your conversation. |
||||
|
* @param outError error information. |
||||
|
* @return a conversation instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration conversationId:(nonnull NSString *)conversationId error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Starts a conversation, and provides asynchronous callback with the information is conversation started successfully or not. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)startConversationAsync:(nonnull void (^)(BOOL started, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Starts a conversation, and provides asynchronous callback with the information is conversation started successfully or not. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)startConversationAsync:(nonnull void (^)(BOOL started, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Ends a conversation, and provides asynchronous callback with the information is conversation ended successfully or not. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)endConversationAsync:(nonnull void (^)(BOOL ended, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Ends a conversation, and provides asynchronous callback with the information is conversation ended successfully or not. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)endConversationAsync:(nonnull void (^)(BOOL ended, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Deletes a conversation, and provides asynchronous callback with the information is conversation deletion completed. |
||||
|
* After deleted, no one will be able to join the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)deleteConversationAsync:(nonnull void (^)(BOOL deleted, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Deletes a conversation, and provides asynchronous callback with the information is conversation deletion completed. |
||||
|
* After deleted, no one will be able to join the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)deleteConversationAsync:(nonnull void (^)(BOOL deleted, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Locks a conversation, and provides asynchronous callback with the information is conversation locking completed. |
||||
|
* After locked, new participants are prevented from joining the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)lockConversationAsync:(nonnull void (^)(BOOL locked, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Locks a conversation, and provides asynchronous callback with the information is conversation locking completed. |
||||
|
* After locked, new participants are prevented from joining the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)lockConversationAsync:(nonnull void (^)(BOOL locked, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Unlocks a conversation, and provides asynchronous callback with the information is conversation unlocking completed. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)unlockConversationAsync:(nonnull void (^)(BOOL unlocked, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Unlocks a conversation, and provides asynchronous callback with the information is conversation unlocking completed. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)unlockConversationAsync:(nonnull void (^)(BOOL unlocked, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Mute all other participants in the conversation. After this no other participants will have their speech recognitions broadcast, |
||||
|
* nor be able to send text messages. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)muteAllParticipantsAsync:(nonnull void (^)(BOOL muted, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Mute all other participants in the conversation. After this no other participants will have their speech recognitions broadcast, |
||||
|
* nor be able to send text messages. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)muteAllParticipantsAsync:(nonnull void (^)(BOOL muted, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Unmute all other participants in the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)unmuteAllParticipantsAsync:(nonnull void (^)(BOOL unmuted, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Unmute all other participants in the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)unmuteAllParticipantsAsync:(nonnull void (^)(BOOL unmuted, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Mute participant with a given userId in the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
*/ |
||||
|
- (void)muteParticipantAsync:(nonnull void (^)(BOOL muted, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Mute participant with a given userId in the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)muteParticipantAsync:(nonnull void (^)(BOOL muted, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Unmute participant with a given userId in the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
*/ |
||||
|
- (void)unmuteParticipantAsync:(nonnull void (^)(BOOL unmuted, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Unmute participant with a given userId in the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)unmuteParticipantAsync:(nonnull void (^)(BOOL unmuted, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Adds a participant from a conversation using a user id. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
*/ |
||||
|
- (void)addParticipantAsync:(nonnull void (^)(SPXParticipant * _Nullable, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Adds a participant from a conversation using a user id. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)addParticipantAsync:(nonnull void (^)(SPXParticipant * _Nullable, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Adds a participant from a conversation using a Participant object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param participant A Participant instance. |
||||
|
*/ |
||||
|
- (void)addParticipantAsync:(nonnull void (^)(SPXParticipant * _Nullable, NSError * _Nullable))completedHandler participant:(nonnull SPXParticipant *)participant |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Adds a participant from a conversation using a Participant object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param participant A Participant instance. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)addParticipantAsync:(nonnull void (^)(SPXParticipant * _Nullable, NSError * _Nullable))completedHandler participant:(nonnull SPXParticipant *)participant error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Adds a participant from a conversation using a User object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param user A User instance. |
||||
|
*/ |
||||
|
- (void)addParticipantAsync:(nonnull void (^)(SPXUser * _Nullable, NSError * _Nullable))completedHandler user:(nonnull SPXUser *)user |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Adds a participant from a conversation using a User object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param user A User instance. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)addParticipantAsync:(nonnull void (^)(SPXUser * _Nullable, NSError * _Nullable))completedHandler user:(nonnull SPXUser *)user error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Remove a participant from a conversation using a user id. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
*/ |
||||
|
- (void)removeParticipantAsync:(nonnull void (^)(BOOL removed, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Remove a participant from a conversation using a user id. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)removeParticipantAsync:(nonnull void (^)(BOOL removed, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Remove a participant from a conversation using a Participant object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param participant A Participant instance. |
||||
|
*/ |
||||
|
- (void)removeParticipantAsync:(nonnull void (^)(BOOL removed, NSError * _Nullable))completedHandler participant:(nonnull SPXParticipant *)participant |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Remove a participant from a conversation using a Participant object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param participant A Participant instance. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)removeParticipantAsync:(nonnull void (^)(BOOL removed, NSError * _Nullable))completedHandler participant:(nonnull SPXParticipant *)participant error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Remove a participant from a conversation using a User object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param user A User instance. |
||||
|
*/ |
||||
|
- (void)removeParticipantAsync:(nonnull void (^)(BOOL removed, NSError * _Nullable))completedHandler user:(nonnull SPXUser *)user |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Remove a participant from a conversation using a User object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param user A User instance. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)removeParticipantAsync:(nonnull void (^)(BOOL removed, NSError * _Nullable))completedHandler user:(nonnull SPXUser *)user error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,40 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSessionEventArgs.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload for conversation expiration event. |
||||
|
* |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConversationExpirationEventArgs : SPXSessionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* Represents the time left until the conversation expires. |
||||
|
*/ |
||||
|
@property (readonly)NSUInteger expirationTime; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload for conversation participant changed event. |
||||
|
* |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConversationParticipantsChangedEventArgs : SPXSessionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* The reason why the participant changed event was raised (e.g. a participant joined). |
||||
|
*/ |
||||
|
@property (readonly)SPXParticipantChangedReason reason; |
||||
|
|
||||
|
/**
|
||||
|
* Represents the list of participant(s) that joined, left, or were updated. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nonnull)NSArray *participants; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,258 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechConfiguration.h" |
||||
|
#import "SPXAudioConfiguration.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
#import "SPXRecognizer.h" |
||||
|
#import "SPXConversation.h" |
||||
|
#import "SPXConversationTranscriptionResult.h" |
||||
|
#import "SPXConversationTranscriptionEventArgs.h" |
||||
|
|
||||
|
/**
|
||||
|
* Performs conversation transcribing for audio input streams, and gets transcribed text and user id as a result. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConversationTranscriber : SPXRecognizer |
||||
|
|
||||
|
typedef void (^SPXConversationTranscriptionEventHandler)(SPXConversationTranscriber * _Nonnull, SPXConversationTranscriptionEventArgs * _Nonnull); |
||||
|
typedef void (^SPXConversationTranscriptionCanceledEventHandler)(SPXConversationTranscriber * _Nonnull, SPXConversationTranscriptionCanceledEventArgs * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* The authorization token used to communicate with the conversation transcription service. |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, |
||||
|
* the caller needs to refresh it by calling this setter with a new valid token. |
||||
|
* Otherwise, the recognizer will encounter errors during recognition. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *authorizationToken; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of a conversation transcriber. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified audio config. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified audio config. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified source language. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param language source language. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration language:(nonnull NSString *)language |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified source language. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param language source language. |
||||
|
* @param outError error information. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
language:(nonnull NSString *)language |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified source language and audio configuration. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param language source language. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
language:(nonnull NSString *)language |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified source language and audio configuration. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param language source language. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
language:(nonnull NSString *)language |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified source language configuration. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param sourceLanguageConfiguration the source language configuration. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
sourceLanguageConfiguration:(nonnull SPXSourceLanguageConfiguration *)sourceLanguageConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified source language configuration. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param sourceLanguageConfiguration the source language configuration. |
||||
|
* @param outError error information. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
sourceLanguageConfiguration:(nonnull SPXSourceLanguageConfiguration *)sourceLanguageConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified source language configuration and audio configuration. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param sourceLanguageConfiguration the source language configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
sourceLanguageConfiguration:(nonnull SPXSourceLanguageConfiguration *)sourceLanguageConfiguration |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified source language configuration and audio configuration. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param sourceLanguageConfiguration the source language configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
sourceLanguageConfiguration:(nonnull SPXSourceLanguageConfiguration *)sourceLanguageConfiguration |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified configuration for auto language detection. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @return a conversation transcriber instance.. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified configuration for auto language detection. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @param outError error information. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified configuration for auto language detection and audio configuration. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of conversation transcriber using the specified configuration for auto language detection and audio configuration. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration for conversation transcription. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return a conversation transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
/**
|
||||
|
* Starts conversation transcribing on a continuous audio stream, until stopTranscribingAsync() is called. |
||||
|
* User must subscribe to events to receive transcription results. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)startTranscribingAsync:(nonnull void (^)(BOOL started, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Starts conversation transcribing on a continuous audio stream, until stopTranscribingAsync() is called. |
||||
|
* User must subscribe to events to receive transcription results. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)startTranscribingAsync:(nonnull void (^)(BOOL started, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops conversation transcribing. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)stopTranscribingAsync:(nonnull void (^)(BOOL stopped, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops conversation transcribing. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)stopTranscribingAsync:(nonnull void (^)(BOOL stopped, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Transcribed event which indicates that a final result has been transcribed. |
||||
|
*/ |
||||
|
- (void)addTranscribedEventHandler:(nonnull SPXConversationTranscriptionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Transcribing event which indicates an that intermediate result has been transcribed. |
||||
|
*/ |
||||
|
- (void)addTranscribingEventHandler:(nonnull SPXConversationTranscriptionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Canceled event which indicates that an error occurred during transcription. |
||||
|
*/ |
||||
|
- (void)addCanceledEventHandler:(nonnull SPXConversationTranscriptionCanceledEventHandler)eventHandler; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,46 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognitionEventArgs.h" |
||||
|
#import "SPXConversationTranscriptionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload for conversation transcription events. |
||||
|
* |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConversationTranscriptionEventArgs : SPXRecognitionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* Represents the conversation transcription result. |
||||
|
*/ |
||||
|
@property (readonly, nullable)SPXConversationTranscriptionResult *result; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of conversation transcription canceled result events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConversationTranscriptionCanceledEventArgs : SPXConversationTranscriptionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* The reason the trancription was canceled. |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationReason reason; |
||||
|
|
||||
|
/**
|
||||
|
* The error code in case of an unsuccessful transcription (reason is set to Error). |
||||
|
* |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationErrorCode errorCode; |
||||
|
|
||||
|
/**
|
||||
|
* The error message in case of an unsuccessful transcription (reason is set to Error). |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *errorDetails; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,20 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognitionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the result of conversation transcription. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConversationTranscriptionResult : SPXRecognitionResult |
||||
|
|
||||
|
/**
|
||||
|
* A string that represents a speaker identifier in the conversation. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *speakerId; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,31 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognitionEventArgs.h" |
||||
|
#import "SPXConversationTranscriptionEventArgs.h" |
||||
|
#import "SPXConversationTranslationResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload for conversation translation events. |
||||
|
* |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConversationTranslationEventArgs : SPXRecognitionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* Represents the conversation translation result. |
||||
|
*/ |
||||
|
@property (readonly, nullable)SPXConversationTranslationResult *result; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of conversation translation canceled result events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConversationTranslationCanceledEventArgs : SPXConversationTranscriptionCanceledEventArgs |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,25 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXTranslationRecognitionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the result of conversation translation. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConversationTranslationResult : SPXTranslationRecognitionResult |
||||
|
|
||||
|
/**
|
||||
|
* A string that represents the original language this result was in. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *originalLang; |
||||
|
|
||||
|
/**
|
||||
|
* A string that represents the unique identifier for the participant this result is for. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *participantId; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,255 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechConfiguration.h" |
||||
|
#import "SPXAudioConfiguration.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
#import "SPXConversation.h" |
||||
|
#import "SPXConversationEventArgs.h" |
||||
|
#import "SPXConversationTranslationResult.h" |
||||
|
#import "SPXConversationTranslationEventArgs.h" |
||||
|
|
||||
|
/**
|
||||
|
* A conversation translator that enables a connected experience where participants can use their |
||||
|
* own devices to see everyone else's recognitions and IMs in their own languages. Participants can |
||||
|
* also speak and send IMs to others. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXConversationTranslator : NSObject |
||||
|
|
||||
|
typedef void (^SPXConversationTranslationEventHandler)(SPXConversationTranslator * _Nonnull, SPXConversationTranslationEventArgs * _Nonnull); |
||||
|
typedef void (^SPXConversationTranslationCanceledEventHandler)(SPXConversationTranslator * _Nonnull, SPXConversationTranslationCanceledEventArgs * _Nonnull); |
||||
|
typedef void (^SPXConversationParticipantsChangedEventHandler)(SPXConversationTranslator * _Nonnull, SPXConversationParticipantsChangedEventArgs * _Nonnull); |
||||
|
typedef void (^SPXConversationExpirationEventHandler)(SPXConversationTranslator * _Nonnull, SPXConversationExpirationEventArgs * _Nonnull); |
||||
|
typedef void (^SPXConversationSessionEventHandler)(SPXConversationTranslator * _Nonnull, SPXSessionEventArgs * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* Authorization token used to communicate with the conversation translation service. |
||||
|
* |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, |
||||
|
* the caller needs to refresh it by calling this setter with a new valid token. |
||||
|
* Otherwise, the recognizer will encounter errors during recognition. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nullable)NSString *authorizationToken; |
||||
|
|
||||
|
/**
|
||||
|
* Participant identifier used for conversation translation. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nullable)NSString *participantId; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of a conversation translator using the default configuration. |
||||
|
* @return a conversation translator instance. |
||||
|
*/ |
||||
|
#pragma clang diagnostic push |
||||
|
#pragma clang diagnostic ignored "-Wnullability" |
||||
|
- (nullable instancetype)init |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
#pragma clang diagnostic pop |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of a conversation translator using the default configuration. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return a conversation translator instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of a conversation translator using the specified audio configuration. |
||||
|
* |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return a conversation translator instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAudioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of a conversation translator using the specified audio configuration. |
||||
|
* |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return a conversation translator instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAudioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Joins an existing conversation. You should use this method if you have created a conversation |
||||
|
* using createConversationAsync. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param conversation conversation instance. |
||||
|
* @param nickname The display name to use for the current participant. |
||||
|
*/ |
||||
|
- (void)joinConversationAsync:(nonnull void (^)(BOOL joined, NSError * _Nullable))completedHandler conversation:(nonnull SPXConversation *)conversation nickname:(nonnull NSString *)nickname |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Joins an existing conversation. You should use this method if you have created a conversation |
||||
|
* using createConversationAsync. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param conversation conversation instance. |
||||
|
* @param nickname The display name to use for the current participant. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)joinConversationAsync:(nonnull void (^)(BOOL joined, NSError * _Nullable))completedHandler conversation:(nonnull SPXConversation *)conversation nickname:(nonnull NSString *)nickname error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Joins an existing conversation. You should use this method if you have created a conversation |
||||
|
* using createConversationAsync. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param conversationId conversation id. |
||||
|
* @param nickname The display name to use for the current participant. |
||||
|
* @param language The speech language to use for the current participant. |
||||
|
*/ |
||||
|
- (void)joinConversationAsync:(nonnull void (^)(BOOL joined, NSError * _Nullable))completedHandler conversationId:(nonnull NSString *)conversationId nickname:(nonnull NSString *)nickname language:(nonnull NSString *)language |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Joins an existing conversation. You should use this method if you have created a conversation |
||||
|
* using createConversationAsync. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param conversationId conversation id. |
||||
|
* @param nickname The display name to use for the current participant. |
||||
|
* @param language The speech language to use for the current participant. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)joinConversationAsync:(nonnull void (^)(BOOL joined, NSError * _Nullable))completedHandler conversationId:(nonnull NSString *)conversationId nickname:(nonnull NSString *)nickname language:(nonnull NSString *)language error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Leave the current conversation. After this is called, you will no longer receive any events. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)leaveConversationAsync:(nonnull void (^)(BOOL left, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Leave the current conversation. After this is called, you will no longer receive any events. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)leaveConversationAsync:(nonnull void (^)(BOOL left, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Sends an instant message to all participants in the conversation. This instant message will |
||||
|
* be translated into each participant's text language. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param message The message to send. |
||||
|
*/ |
||||
|
- (void)sendTextMessageAsync:(nonnull void (^)(BOOL sent, NSError * _Nullable))completedHandler message:(nonnull NSString *)message |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Sends an instant message to all participants in the conversation. This instant message will |
||||
|
* be translated into each participant's text language. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param message The message to send. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)sendTextMessageAsync:(nonnull void (^)(BOOL sent, NSError * _Nullable))completedHandler message:(nonnull NSString *)message error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Starts sending audio to the conversation service for speech recognition and translation. You |
||||
|
* should subscribe to the Transcribing, and Transcribed events to receive conversation |
||||
|
* translation results for yourself, and other participants in the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)startTranscribingAsync:(nonnull void (^)(BOOL started, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Starts sending audio to the conversation service for speech recognition and translation. You |
||||
|
* should subscribe to the Transcribing, and Transcribed events to receive conversation |
||||
|
* translation results for yourself, and other participants in the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)startTranscribingAsync:(nonnull void (^)(BOOL started, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops sending audio to the conversation service. You will still receive Transcribing, and |
||||
|
* Transcribed events for other participants in the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)stopTranscribingAsync:(nonnull void (^)(BOOL stopped, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops sending audio to the conversation service. You will still receive Transcribing, and |
||||
|
* Transcribed events for other participants in the conversation. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)stopTranscribingAsync:(nonnull void (^)(BOOL stopped, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the Cognitive Speech authorization token that will be used for connecting to the server. |
||||
|
* |
||||
|
* @param authToken The authorization token. |
||||
|
* @param region The Azure region for this token. |
||||
|
*/ |
||||
|
- (void)setAuthorizationToken:(nonnull NSString *)authToken region:(nonnull NSString *)region |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Sets the Cognitive Speech authorization token that will be used for connecting to the server. |
||||
|
* |
||||
|
* @param authToken The authorization token. |
||||
|
* @param region The Azure region for this token. |
||||
|
*/ |
||||
|
- (BOOL)setAuthorizationToken:(nonnull NSString *)authToken region:(nonnull NSString *)region error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Transcribed event which indicates that a final result has been transcribed. |
||||
|
*/ |
||||
|
- (void)addTranscribedEventHandler:(nonnull SPXConversationTranslationEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Transcribing event which indicates an that intermediate result has been transcribed. |
||||
|
*/ |
||||
|
- (void)addTranscribingEventHandler:(nonnull SPXConversationTranslationEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the TextMessageReceived event that signals a translated text message from a conversation participant. |
||||
|
*/ |
||||
|
- (void)addTextMessageReceivedEventHandler:(nonnull SPXConversationTranslationEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Canceled event which indicates that an error occurred during transcription. |
||||
|
*/ |
||||
|
- (void)addCanceledEventHandler:(nonnull SPXConversationTranslationCanceledEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the ConversationParticipantsChanged event that signals participants in the room have changed (e.g. a new participant joined). |
||||
|
*/ |
||||
|
- (void)addConversationParticipantsChangedEventHandler:(nonnull SPXConversationParticipantsChangedEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the ConversationExpiration event that signals how many more minutes are left before the conversation expires. |
||||
|
*/ |
||||
|
- (void)addConversationExpirationEventHandler:(nonnull SPXConversationExpirationEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the SessionStarted event using the specified handler. |
||||
|
*/ |
||||
|
- (void)addSessionStartedEventHandler:(nonnull SPXConversationSessionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the SessionStopped event using the specified handler. |
||||
|
*/ |
||||
|
- (void)addSessionStoppedEventHandler:(nonnull SPXConversationSessionEventHandler)eventHandler; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,320 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
|
||||
|
/**
|
||||
|
* The base configuration type used to create a DialogServiceConnector that can communicate with a voice assistant. |
||||
|
* |
||||
|
* SPXDialogServiceConfiguration objects should be initialized directly. Derived objects like |
||||
|
* SPXDialogBotFrameworkConfiguration should be instantiated, instead. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXDialogServiceConfiguration : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The language identifier used for speech-to-text, expressed in BCP-47 format. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *language; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the value of a configuration property using an explicit string literal as a key. |
||||
|
* If a property with the provided key is not available, an empty string is returned. |
||||
|
* |
||||
|
* @param name the name of the configuration property used as a key to the desired value. |
||||
|
* @return the value of the indexed configuration property or an empty string if the key is not found. |
||||
|
*/ |
||||
|
- (nullable NSString *)getPropertyByName:(nonnull NSString *)name; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the value of a configuration property using a known property ID as a key. |
||||
|
* If a property with the provided key is not available, an empty string is returned. |
||||
|
* |
||||
|
* @param propertyId the property ID for the configuration property. |
||||
|
* @return the value of the configuration property or an empty string if the key is not found. |
||||
|
*/ |
||||
|
- (nullable NSString *)getPropertyById:(SPXPropertyId)propertyId; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the value of a configuration property using a provided string literal as the key. |
||||
|
* |
||||
|
* @param value the value to set for the configuration property. |
||||
|
* @param name the name of the configuration property to use as a key for its value. |
||||
|
*/ |
||||
|
- (void)setPropertyTo:(nonnull NSString *)value byName:(nonnull NSString *)name; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the value of a configuration property using a known property ID as the key. |
||||
|
* |
||||
|
* @param value the value to set for the configuration property. |
||||
|
* @param id the property ID for the configuration property. |
||||
|
*/ |
||||
|
- (void)setPropertyTo:(nonnull NSString *)value byId:(SPXPropertyId)id; |
||||
|
|
||||
|
/**
|
||||
|
* Sets an advanced configuration property that's encoded into the speech service request upon connection. |
||||
|
* This is typically used for preview features not available via a well-supported property ID. |
||||
|
* |
||||
|
* @param value the property value. |
||||
|
* @param name the property name. |
||||
|
* @param channel the channel used to pass the specified property to service. |
||||
|
*/ |
||||
|
- (void)setServicePropertyTo |
||||
|
:(nonnull NSString *)value |
||||
|
byName:(nonnull NSString *)name |
||||
|
usingChannel:(SPXServicePropertyChannel)channel; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* The specialized configuration type used to initialize a DialogServiceConnector that will connect to a Bot Framework |
||||
|
* bot using the Direct Line Speech channel. |
||||
|
* |
||||
|
* See also: [What is Direct Line Speech?](/azure/cognitive-services/speech-service/direct-line-speech). |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXDialogBotFrameworkConfiguration : SPXDialogServiceConfiguration |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a dialog configuration object used to create a DialogServiceConnector that will communicate with a Bot |
||||
|
* Framework bot via the Direct Line Speech channel. |
||||
|
* |
||||
|
* @param subscriptionKey the subscription key to be used. |
||||
|
* @param region the region name for the subscription (see the <a href="https://aka.ms/csspeech/region">region |
||||
|
* page</a>). |
||||
|
* @param botId the identifier of a specific bot resource to request, even if it's not the default for this |
||||
|
* subscription. |
||||
|
* @param outError error information. |
||||
|
* @return a configuration object used to initialize a DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSubscription |
||||
|
:(nonnull NSString *)subscriptionKey |
||||
|
region:(nonnull NSString *)region |
||||
|
botId:(NSString * _Nullable)botId |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a dialog configuration object used to create a DialogServiceConnector that will communicate with a Bot |
||||
|
* Framework bot. |
||||
|
* |
||||
|
* @param subscriptionKey the subscription key to be used. |
||||
|
* @param region the region name for the subscription (see the <a href="https://aka.ms/csspeech/region">region |
||||
|
* page</a>). |
||||
|
* @param botId the identifier of a specific bot resource to request, even if it's not the default for this |
||||
|
* subscription. |
||||
|
* @return a configuration object used to initialize a DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nonnull instancetype)initWithSubscription |
||||
|
:(nonnull NSString *)subscriptionKey |
||||
|
region:(nonnull NSString *)region |
||||
|
botId:(NSString * _Nullable)botId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a dialog configuration object used to create a DialogServiceConnector that will communicate with a Bot |
||||
|
* Framework bot. |
||||
|
* This will connect to the default bot associated with the Direct Line Speech channel for the speech service resource. |
||||
|
* |
||||
|
* @param subscriptionKey the subscription key to be used. |
||||
|
* @param region the region name for the subscription (see the <a href="https://aka.ms/csspeech/region">region |
||||
|
* page</a>). |
||||
|
* @param outError error information. |
||||
|
* @return a configuration object used to initialize a DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSubscription |
||||
|
:(nonnull NSString *)subscriptionKey |
||||
|
region:(nonnull NSString *)region |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a dialog configuration object used to create a DialogServiceConnector that will communicate with a Bot |
||||
|
* Framework bot. |
||||
|
* This will connect to the default bot associated with the Direct Line Speech channel for the speech service resource. |
||||
|
* |
||||
|
* @param subscriptionKey the subscription key to be used. |
||||
|
* @param region the region name for the subscription (see the <a href="https://aka.ms/csspeech/region">region |
||||
|
* page</a>). |
||||
|
* @return a configuration object used to initialize a DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nonnull instancetype)initWithSubscription:(nonnull NSString *)subscriptionKey region:(nonnull NSString *)region |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a dialog configuration object used to create a DialogServiceConnector that will communicate with a Bot |
||||
|
* Framework bot. |
||||
|
* |
||||
|
* Note: An authorization token must be obtained before this call and checked for validity. Before an authorization |
||||
|
* token expires, it must be refreshed by assigning a new token on the corresponding property present on the |
||||
|
* DialogServiceConnector created with the configuration object created with this call. |
||||
|
* |
||||
|
* @param authorizationToken the authorization token. |
||||
|
* @param region the region name for the subscription (see the <a href="https://aka.ms/csspeech/region">region |
||||
|
* page</a>). |
||||
|
* @param botId the identifier of a specific bot resource to request, even if it's not the default for this |
||||
|
* subscription. |
||||
|
* @param outError error information. |
||||
|
* @return a configuration object used to initialize a DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAuthorizationToken |
||||
|
:(nonnull NSString *)authorizationToken |
||||
|
region:(nonnull NSString *)region |
||||
|
botId:(NSString * _Nullable)botId |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a dialog configuration object used to create a DialogServiceConnector that will communicate with a Bot |
||||
|
* Framework bot. |
||||
|
* |
||||
|
* Note: An authorization token must be obtained before this call and checked for validity. Before an authorization |
||||
|
* token expires, it must be refreshed by assigning a new token on the corresponding property present on the |
||||
|
* DialogServiceConnector created with the configuration object created with this call. |
||||
|
* |
||||
|
* @param authorizationToken the authorization token. |
||||
|
* @param region the region name for the subscription (see the <a href="https://aka.ms/csspeech/region">region |
||||
|
* page</a>). |
||||
|
* @param botId the identifier of a specific bot resource to request, even if it's not the default for this |
||||
|
* subscription. |
||||
|
* @return a configuration object used to initialize a DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nonnull instancetype)initWithAuthorizationToken |
||||
|
:(nonnull NSString *)authorizationToken |
||||
|
region:(nonnull NSString *)region |
||||
|
botId:(NSString * _Nullable)botId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a dialog configuration object used to create a DialogServiceConnector that will communicate with a Bot |
||||
|
* Framework bot. |
||||
|
* This will connect to the default bot associated with the Direct Line Speech channel for the speech service resource. |
||||
|
* |
||||
|
* Note: An authorization token must be obtained before this call and checked for validity. Before an authorization |
||||
|
* token expires, it must be refreshed by assigning a new token on the corresponding property present on the |
||||
|
* DialogServiceConnector created with the configuration object created with this call. |
||||
|
* |
||||
|
* @param authorizationToken the authorization token. |
||||
|
* @param region the region name for the subscription (see the <a href="https://aka.ms/csspeech/region">region |
||||
|
* page</a>). |
||||
|
* @param outError error information. |
||||
|
* @return a configuration object used to initialize a DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAuthorizationToken |
||||
|
:(nonnull NSString *)authorizationToken |
||||
|
region:(nonnull NSString *)region |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a dialog configuration object used to create a DialogServiceConnector that will communicate with a Bot |
||||
|
* Framework bot. |
||||
|
* This will connect to the default bot associated with the Direct Line Speech channel for the speech service resource. |
||||
|
* |
||||
|
* Note: An authorization token must be obtained before this call and checked for validity. Before an authorization |
||||
|
* token expires, it must be refreshed by assigning a new token on the corresponding property present on the |
||||
|
* DialogServiceConnector created with the configuration object created with this call. |
||||
|
* |
||||
|
* @param authorizationToken the authorization token. |
||||
|
* @param region the region name for the subscription (see the <a href="https://aka.ms/csspeech/region">region |
||||
|
* page</a>). |
||||
|
* @return a configuration object used to initialize a DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nonnull instancetype)initWithAuthorizationToken |
||||
|
:(nonnull NSString *)authorizationToken |
||||
|
region:(nonnull NSString *)region |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* The instance interface type used to initialize a DialogServiceConnector that will connect to a Custom Commands |
||||
|
* application as published from Speech Studio for a speech service resource. |
||||
|
* |
||||
|
* See also: [What is Custom Commands?](/azure/cognitive-services/speech-service/custom-commands). |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXDialogCustomCommandsConfiguration : SPXDialogServiceConfiguration |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a dialog configuration object used to create a DialogServiceConnector that will communicate with a |
||||
|
* Custom Commands application. |
||||
|
* Requires an identifier for a published Custom Commands application associated with the referenced speech service |
||||
|
* resource. |
||||
|
* |
||||
|
* @param subscriptionKey the subscription key to be used. |
||||
|
* @param appId the identifier for the Custom Commands application to use, as selected from the subscription. |
||||
|
* @param region the region name for the subscription (see the <a href="https://aka.ms/csspeech/region">region |
||||
|
* page</a>). |
||||
|
* @param outError error information. |
||||
|
* @return a configuration object used to initialize a DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSubscription |
||||
|
:(nonnull NSString *)subscriptionKey |
||||
|
appId:(nonnull NSString *)appId |
||||
|
region:(nonnull NSString *)region |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a dialog configuration object used to create a DialogServiceConnector that will communicate with a |
||||
|
* Custom Commands application. |
||||
|
* Requires an identifier for a published Custom Commands application associated with the referenced speech service |
||||
|
* resource. |
||||
|
* |
||||
|
* @param subscriptionKey the subscription key to be used. |
||||
|
* @param appId the identifier for the Custom Commands application to use, as selected from the subscription. |
||||
|
* @param region the region name for the subscription (see the <a href="https://aka.ms/csspeech/region">region |
||||
|
* page</a>). |
||||
|
* @return a configuration object used to initialize a DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nonnull instancetype)initWithSubscription |
||||
|
:(nonnull NSString *)subscriptionKey |
||||
|
appId:(nonnull NSString *)appId |
||||
|
region:(nonnull NSString *)region |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a dialog configuration object used to create a DialogServiceConnector that will communicate with a |
||||
|
* Custom Commands application. |
||||
|
* Requires an identifier for a published Custom Commands application associated with the referenced speech service |
||||
|
* resource. |
||||
|
* |
||||
|
* Note: An authorization token must be obtained before this call and checked for validity. Before an authorization |
||||
|
* token expires, it must be refreshed by assigning a new token on the corresponding property present on the |
||||
|
* DialogServiceConnector created with the configuration object created with this call. |
||||
|
* |
||||
|
* @param authorizationToken the authorization token. |
||||
|
* @param appId the identifier for the Custom Commands application to use, as selected from the subscription. |
||||
|
* @param region the region name for the subscription (see the <a href="https://aka.ms/csspeech/region">region |
||||
|
* page</a>). |
||||
|
* @param outError error information. |
||||
|
* @return a configuration object used to initialize a DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAuthorizationToken |
||||
|
:(nonnull NSString *)authorizationToken |
||||
|
appId:(nonnull NSString *)appId |
||||
|
region:(nonnull NSString *)region |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a dialog configuration object used to create a DialogServiceConnector that will communicate with a |
||||
|
* Custom Commands application. |
||||
|
* Requires an identifier for a published Custom Commands application associated with the referenced speech service |
||||
|
* resource. |
||||
|
* |
||||
|
* Note: An authorization token must be obtained before this call and checked for validity. Before an authorization |
||||
|
* token expires, it must be refreshed by assigning a new token on the corresponding property present on the |
||||
|
* DialogServiceConnector created with the configuration object created with this call. |
||||
|
* |
||||
|
* @param authorizationToken the authorization token. |
||||
|
* @param appId the identifier for the Custom Commands application to use, as selected from the subscription. |
||||
|
* @param region the region name for the subscription (see the <a href="https://aka.ms/csspeech/region">region |
||||
|
* page</a>). |
||||
|
* @return a configuration object used to initialize a DialogServiceConnector. |
||||
|
*/ |
||||
|
- (nonnull instancetype)initWithAuthorizationToken |
||||
|
:(nonnull NSString *)authorizationToken |
||||
|
appId:(nonnull NSString *)appId |
||||
|
region:(nonnull NSString *)region |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,592 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXDialogServiceConnectorActivityReceivedEventArgs.h" |
||||
|
#import "SPXAudioConfiguration.h" |
||||
|
#import "SPXAutoDetectSourceLanguageConfiguration.h" |
||||
|
#import "SPXKeywordRecognitionModel.h" |
||||
|
#import "SPXSourceLanguageConfiguration.h" |
||||
|
#import "SPXDialogServiceConfiguration.h" |
||||
|
#import "SPXDialogServiceConnector.h" |
||||
|
#import "SPXDialogServiceConnectorTurnStatusReceivedEventArgs.h" |
||||
|
#import "SPXSpeechRecognitionResult.h" |
||||
|
#import "SPXSpeechRecognitionEventArgs.h" |
||||
|
#import "SPXSessionEventArgs.h" |
||||
|
|
||||
|
/**
|
||||
|
* An object that communicates with a speech-enabled dialog system using either the Bot Framework or Custom Commands. |
||||
|
* This type receives speech-to-text results and also facilitates the asynchronous sending and receiving of non-speech |
||||
|
* dialog activity data. |
||||
|
* |
||||
|
* See also: |
||||
|
* [Integrate with a client application using Speech SDK](/azure/cognitive-services/speech-service/how-to-custom-commands-setup-speech-sdk), |
||||
|
* [Voice assistants frequently asked questions](/azure/cognitive-services/speech-service/faq-voice-assistants), |
||||
|
* [What is Custom Commands?](/azure/cognitive-services/speech-service/custom-commands) |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXDialogServiceConnector : SPXRecognizer |
||||
|
|
||||
|
/**
|
||||
|
* Handler type provided to listenOnceAsync that receives speech-to-text results upon completion. |
||||
|
*/ |
||||
|
typedef void (^SPXDialogServiceConnectorRecognitionResultHandler)(SPXSpeechRecognitionResult * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* Handler type provided to sendActivityAsync that receives interaction identifiers, as strings, upon completion. |
||||
|
*/ |
||||
|
typedef void (^SPXDialogServiceConnectorInteractionIdHandler)(NSString * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* Handler type provided to async methods without async result data that is invoked when an asynchronous stop operation |
||||
|
* completes. |
||||
|
*/ |
||||
|
typedef void (^SPXDialogServiceConnectorAsyncCompletionHandler)(void); |
||||
|
|
||||
|
/**
|
||||
|
* Handler type provided to receieve event information for intermediate and final speech-to-text results. |
||||
|
*/ |
||||
|
typedef void (^SPXDialogServiceConnectorRecognitionEventHandler)(SPXDialogServiceConnector * _Nonnull, SPXSpeechRecognitionEventArgs * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* Handler type provided to receive event information for cancellation events as raised when errors or end of input |
||||
|
* occurs. |
||||
|
*/ |
||||
|
typedef void (^SPXDialogServiceConnectorCanceledEventHandler)(SPXDialogServiceConnector * _Nonnull, SPXSpeechRecognitionCanceledEventArgs * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* Handler type provided to receive turn status information from the connected dialog implementation. |
||||
|
*/ |
||||
|
typedef void (^SPXDialogServiceConnectorTurnStatusReceivedEventHandler)(SPXDialogServiceConnector * _Nonnull, SPXDialogServiceConnectorTurnStatusReceivedEventArgs * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* Handler type provided to receive activity events from connected dialog implementation. |
||||
|
*/ |
||||
|
typedef void (^SPXDialogServiceConnectorActivityReceivedEventHandler)(SPXDialogServiceConnector * _Nonnull, SPXDialogServiceConnectorActivityReceivedEventArgs * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* The authorization token used to communicate with the speech service. |
||||
|
* |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, |
||||
|
* the caller needs to refresh it by calling this setter with a new valid token. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *authorizationToken; |
||||
|
|
||||
|
/**
|
||||
|
* A JSON template for activity payload data that will be provided to the speech service for the next conversation. |
||||
|
* The service will attempt to merge this template into all activities sent to the dialog backend, whether originated |
||||
|
* by the client with SendActivityAsync or generated by the service, as is the case with speech-to-text results. This |
||||
|
* allows a client to ensure consistent metadata information is provided to the dialog implementation across |
||||
|
* interactions. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *speechActivityTemplate; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of dialog service connector that will use the default audio input device for any |
||||
|
* speech-to-text interactions. |
||||
|
* |
||||
|
* @param dialogServiceConfiguration the configuration object that includes information about the selected dialog |
||||
|
* system. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of a dialog service connector. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithDialogServiceConfiguration |
||||
|
:(nonnull SPXDialogServiceConfiguration *)dialogServiceConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of dialog service connector that will use the default audio input device for any |
||||
|
* speech-to-text interactions. |
||||
|
* |
||||
|
* @param dialogServiceConfiguration the configuration object that includes information about the selected dialog |
||||
|
* system. |
||||
|
* @return an instance of a dialog service connector. |
||||
|
*/ |
||||
|
- (nonnull instancetype)initWithDialogServiceConfiguration |
||||
|
:(nonnull SPXDialogServiceConfiguration *)dialogServiceConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of dialog service connector using the specified audio configuration. |
||||
|
* |
||||
|
* @param dialogServiceConfiguration the configuration object that includes information about the selected dialog |
||||
|
* system. |
||||
|
* @param audioConfiguration the configuration object for input audio as used by speech-to-text interactions. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of a dialog service connector. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithDialogServiceConfiguration |
||||
|
:(nonnull SPXDialogServiceConfiguration *)dialogServiceConfiguration |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of dialog service connector using the specified audio configuration. |
||||
|
* |
||||
|
* @param dialogServiceConfiguration the configuration object that includes information about the selected dialog |
||||
|
* system. |
||||
|
* @param audioConfiguration the configuration object for input audio as used by speech-to-text interactions. |
||||
|
* @return an instance of a dialog service connector. |
||||
|
*/ |
||||
|
- (nonnull instancetype)initWithDialogServiceConfiguration |
||||
|
:(nonnull SPXDialogServiceConfiguration *)dialogServiceConfiguration |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Begins a speech-to-text interaction with this connector and blocks until a single speech-to-text final result is |
||||
|
* received. The speech-to-text result received is also provided to the configured dialog implementation and that dialog |
||||
|
* system may produce any number of activity payloads in response to the speech interaction. Speech interactions may be |
||||
|
* correlated with activities via dialog-specific data in the activity payload. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return the speech-to-text result from the single-shot speech interaction. |
||||
|
*/ |
||||
|
- (nullable SPXSpeechRecognitionResult *)listenOnce:(NSError * _Nullable * _Nullable)outError NS_RETURNS_RETAINED; |
||||
|
|
||||
|
/**
|
||||
|
* Begins a speech-to-text interaction with this connector and blocks until a single speech-to-text final result is |
||||
|
* received. The speech-to-text result received is also provided to the configured dialog implementation and that dialog |
||||
|
* system may produce any number of activity payloads in response to the speech interaction. Speech interactions may be |
||||
|
* correlated with activities via dialog-specific data in the activity payload. |
||||
|
* |
||||
|
* @return the speech-to-text result from the single-shot speech interaction. |
||||
|
*/ |
||||
|
- (nonnull SPXSpeechRecognitionResult *)listenOnce |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling.") NS_RETURNS_RETAINED; |
||||
|
|
||||
|
/**
|
||||
|
* Asynchronously begins a speech-to-text interaction with this connector and immediately returns execution to the |
||||
|
* calling thread. When received, speech-to-text results may be processed by the provided result handler or retrieved |
||||
|
* via a subscription to the recognized event. The speech-to-text result produced by this operation is also provided to |
||||
|
* the configured dialog implementation and that dialog system may produce any number of activity payloads in response |
||||
|
* to the speech interaction. Speech interactions may be correlated with activities via dialog-specific data in the |
||||
|
* activity payload. |
||||
|
* |
||||
|
* @param resultReceivedHandler the handler function called when a final speech-to-text result is received. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the request to listen started successfully. If NO, additional detail may be |
||||
|
* available in outError. |
||||
|
*/ |
||||
|
- (BOOL)listenOnceAsync |
||||
|
:(nonnull SPXDialogServiceConnectorRecognitionResultHandler)resultReceivedHandler |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Asynchronously begins a speech-to-text interaction with this connector and immediately returns execution to the |
||||
|
* calling thread. When received, speech-to-text results may be processed by the provided result handler or retrieved |
||||
|
* via a subscription to the recognized event. The speech-to-text result produced by this operation is also provided to |
||||
|
* the configured dialog implementation and that dialog system may produce any number of activity payloads in response |
||||
|
* to the speech interaction. Speech interactions may be correlated with activities via dialog-specific data in the |
||||
|
* activity payload. |
||||
|
* |
||||
|
* @param resultReceivedHandler the handler function called when a final speech-to-text result is received. |
||||
|
*/ |
||||
|
- (void)listenOnceAsync:(nonnull SPXDialogServiceConnectorRecognitionResultHandler)resultReceivedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Requests an immediate stop to any active listening operation. This may interrupt a speech-to-text interaction in |
||||
|
* progress and any speech-to-text result received may represent an incomplete speech input. |
||||
|
* |
||||
|
* Synchronous methods should not be called when handling an event. Use stopListeningAsync if a stop is desired in |
||||
|
* response to an event. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether a request to stop was received successfully. If NO, additional information may be |
||||
|
* available in outError. |
||||
|
*/ |
||||
|
- (BOOL)stopListening:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Requests an immediate stop to any active listening operation. This may interrupt a speech-to-text interaction in |
||||
|
* progress and any speech-to-text result received may represent an incomplete speech input. |
||||
|
* |
||||
|
* Synchronous methods should not be called when handling an event. Use stopListeningAsync if a stop is desired in |
||||
|
* response to an event. |
||||
|
*/ |
||||
|
- (void)stopListening |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Requests an immediate stop to any active listening operation. This may interrupt a speech-to-text interaction in |
||||
|
* progress and any speech-to-text result received may represent an incomplete speech input. |
||||
|
* |
||||
|
* @param completionHandler the handler function called when the stop request has completed. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether a request to stop was received successfully. If NO, additional information may be |
||||
|
* available in outError. |
||||
|
*/ |
||||
|
- (BOOL)stopListeningAsync |
||||
|
:(nonnull SPXDialogServiceConnectorAsyncCompletionHandler)completionHandler |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Requests an immediate stop to any active listening operation. This may interrupt a speech-to-text interaction in |
||||
|
* progress and any speech-to-text result received may represent an incomplete speech input. |
||||
|
* |
||||
|
* @param completionHandler the handler function called when the stop request has completed. |
||||
|
*/ |
||||
|
- (void)stopListeningAsync:(nonnull SPXDialogServiceConnectorAsyncCompletionHandler)completionHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Sends a data payload to dialog implementation that this DialogServiceConnector instance is connected to. This is |
||||
|
* usually a JSON document with its schema determined by the dialog implementation and the contents of a sent activity |
||||
|
* should be populated with knowledge about the format and content expectations of the dialog system. |
||||
|
* |
||||
|
* Sent activities are not associated with any other interaction and will generate their own standalone interaction |
||||
|
* identifier when processed by the service. Correlation of conversations and other interactions should be |
||||
|
* accomplished via the activity payload itself using the capabilities of the dialog implementation used. |
||||
|
* |
||||
|
* See also: |
||||
|
* <a href="https://github.com/microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md">Bot Framework -- Activity schema</a>, |
||||
|
* [Quickstart: Create a custom voice assistant](/azure/cognitive-services/speech-service/quickstarts/voice-assistants) (with sendActivity example)</a> |
||||
|
* |
||||
|
* @param activity the serialized payload of an activity to send. |
||||
|
* @param outError error information. |
||||
|
* @return an interaction identifier acquired when the activity is sent to the service. This may occur before the |
||||
|
* activity is processed and evaluated by the dialog implementation and the receipt of an interaction identifier does |
||||
|
* not indicate any success or failure in processing the activity. Information about success or failure may be obtained |
||||
|
* via response activities with correlation data or with TurnStatusReceived events that correlate to this interaction |
||||
|
* identifier. |
||||
|
*/ |
||||
|
- (nullable NSString *)sendActivity |
||||
|
:(nonnull NSString *)activity |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Sends a data payload to dialog implementation that this DialogServiceConnector instance is connected to. This is |
||||
|
* usually a JSON document with its schema determined by the dialog implementation and the contents of a sent activity |
||||
|
* should be populated with knowledge about the format and content expectations of the dialog system. |
||||
|
* |
||||
|
* Sent activities are not associated with any other interaction and will generate their own standalone interaction |
||||
|
* identifier when processed by the service. Correlation of conversations and other interactions should be |
||||
|
* accomplished via the activity payload itself using the capabilities of the dialog implementation used. |
||||
|
* |
||||
|
* See also: |
||||
|
* <a href="https://github.com/microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md">Bot Framework -- Activity schema</a>, |
||||
|
* [Quickstart: Create a custom voice assistant](/azure/cognitive-services/speech-service/quickstarts/voice-assistants) (with sendActivity example)</a> |
||||
|
* |
||||
|
* @param activity the serialized payload of an activity to send. |
||||
|
* @return an interaction identifier acquired when the activity is sent to the service. This may occur before the |
||||
|
* activity is processed and evaluated by the dialog implementation and the receipt of an interaction identifier does |
||||
|
* not indicate any success or failure in processing the activity. Information about success or failure may be obtained |
||||
|
* via response activities with correlation data or with TurnStatusReceived events that correlate to this interaction |
||||
|
* identifier. |
||||
|
*/ |
||||
|
- (nonnull NSString *)sendActivity:(nonnull NSString *)activity |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Sends a data payload to dialog implementation that this DialogServiceConnector instance is connected to. This is |
||||
|
* usually a JSON document with its schema determined by the dialog implementation and the contents of a sent activity |
||||
|
* should be populated with knowledge about the format and content expectations of the dialog system. |
||||
|
* |
||||
|
* Sent activities are not associated with any other interaction and will generate their own standalone interaction |
||||
|
* identifier when processed by the service. Correlation of conversations and other interactions should be |
||||
|
* accomplished via the activity payload itself using the capabilities of the dialog implementation used. |
||||
|
* |
||||
|
* @param activity the serialized payload of an activity to send. |
||||
|
* @param interactionIdReceivedHandler a handler function called when the activity is sent to the service. This may occur |
||||
|
* before the activity is processed and evaluated by the dialog implementation and the receipt of an interaction |
||||
|
* identifier does not indicate any success or failure in processing the activity. Information about success or failure |
||||
|
* may be obtained via response activities with correlation data or with TurnStatusReceived events that correlate to |
||||
|
* this interaction identifier. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the request to send an activity started successfully. If NO, additional |
||||
|
* information may be available in outError. |
||||
|
*/ |
||||
|
- (BOOL)sendActivityAsync |
||||
|
:(NSString * _Nonnull)activity |
||||
|
interactionIdReceivedHandler:(nonnull SPXDialogServiceConnectorInteractionIdHandler)interactionIdReceivedHandler |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Sends a data payload to dialog implementation that this DialogServiceConnector instance is connected to. This is |
||||
|
* usually a JSON document with its schema determined by the dialog implementation and the contents of a sent activity |
||||
|
* should be populated with knowledge about the format and content expectations of the dialog system. |
||||
|
* |
||||
|
* Sent activities are not associated with any other interaction and will generate their own standalone interaction |
||||
|
* identifier when processed by the service. Correlation of conversations and other interactions should be |
||||
|
* accomplished via the activity payload itself using the capabilities of the dialog implementation used. |
||||
|
* |
||||
|
* See also: |
||||
|
* <a href="https://github.com/microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md">Bot Framework -- Activity schema</a>, |
||||
|
* [Quickstart: Create a custom voice assistant](/azure/cognitive-services/speech-service/quickstarts/voice-assistants) (with sendActivityAsync example)</a> |
||||
|
* |
||||
|
* @param activity the serialized payload of an activity to send. |
||||
|
* @param interactionIdReceivedHandler a handler function called when the activity is sent to the service. This may occur |
||||
|
* before the activity is processed and evaluated by the dialog implementation and the receipt of an interaction |
||||
|
* identifier does not indicate any success or failure in processing the activity. Information about success or failure |
||||
|
* may be obtained via response activities with correlation data or with TurnStatusReceived events that correlate to |
||||
|
* this interaction identifier. |
||||
|
*/ |
||||
|
- (void)sendActivityAsync |
||||
|
:(NSString * _Nonnull)activity |
||||
|
interactionIdReceivedHandler:(nonnull SPXDialogServiceConnectorInteractionIdHandler)interactionIdReceivedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Begins a speech-to-text interaction with this connector using a keyword. This interaction will use the provided |
||||
|
* keyword model to listen for a keyword indefinitely, during which audio is not sent to the speech service and all |
||||
|
* processing is performed locally. When a keyword is recognized, the DialogServiceConnector will automatically connect |
||||
|
* to the speech service and begin sending audio data from just before the keyword as if listenOnceAsync() were invoked. |
||||
|
* When received, speech-to-text results may be processed by the provided result handler or retrieved via a subscription |
||||
|
* to the recognized event. The speech-to-text result produced by this operation is also provided to the configured |
||||
|
* dialog implementation and that dialog system may produce any number of activity payloads in response to the speech |
||||
|
* interaction. Speech interactions may be correlated with activities via dialog-specific data in the activity payload. |
||||
|
* |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the requested keyword recognition successfully started. If NO, outError may |
||||
|
* contain additional information. |
||||
|
*/ |
||||
|
- (BOOL)startKeywordRecognition |
||||
|
:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Begins a speech-to-text interaction with this connector using a keyword. This interaction will use the provided |
||||
|
* keyword model to listen for a keyword indefinitely, during which audio is not sent to the speech service and all |
||||
|
* processing is performed locally. When a keyword is recognized, the DialogServiceConnector will automatically connect |
||||
|
* to the speech service and begin sending audio data from just before the keyword as if listenOnceAsync() were invoked. |
||||
|
* When received, speech-to-text results may be processed by the provided result handler or retrieved via a subscription |
||||
|
* to the recognized event. The speech-to-text result produced by this operation is also provided to the configured |
||||
|
* dialog implementation and that dialog system may produce any number of activity payloads in response to the speech |
||||
|
* interaction. Speech interactions may be correlated with activities via dialog-specific data in the activity payload. |
||||
|
* |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
*/ |
||||
|
- (void)startKeywordRecognition:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Asynchronously begins a speech-to-text interaction with this connector and immediately returns execution to the |
||||
|
* calling thread. This interaction will use the provided keyword model to listen for a keyword indefinitely, during |
||||
|
* which audio is not sent to the speech service and all processing is performed locally. When a keyword is recognized, |
||||
|
* the DialogServiceConnector will automatically connect to the speech service and begin sending audio data from just |
||||
|
* before the keyword as if listenOnceAsync() were invoked. When received, speech-to-text results may be processed by |
||||
|
* the provided result handler or retrieved via a subscription to the recognized event. The speech-to-text result |
||||
|
* produced by this operation is also provided to the configured dialog implementation and that dialog system may |
||||
|
* produce any number of activity payloads in response to the speech interaction. Speech interactions may be correlated |
||||
|
* with activities via dialog-specific data in the activity payload. |
||||
|
* |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
* @param completionHandler the handler function called when keyword recognition has started. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the request to start keyword recognition was received successfully. If NO, |
||||
|
* additional information may available in outError. |
||||
|
*/ |
||||
|
- (BOOL)startKeywordRecognitionAsync |
||||
|
:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
completionHandler:(nonnull SPXDialogServiceConnectorAsyncCompletionHandler)completionHandler |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Asynchronously begins a speech-to-text interaction with this connector and immediately returns execution to the |
||||
|
* calling thread. This interaction will use the provided keyword model to listen for a keyword indefinitely, during |
||||
|
* which audio is not sent to the speech service and all processing is performed locally. When a keyword is recognized, |
||||
|
* the DialogServiceConnector will automatically connect to the speech service and begin sending audio data from just |
||||
|
* before the keyword as if listenOnceAsync() were invoked. When received, speech-to-text results may be processed by |
||||
|
* the provided result handler or retrieved via a subscription to the recognized event. The speech-to-text result |
||||
|
* produced by this operation is also provided to the configured dialog implementation and that dialog system may |
||||
|
* produce any number of activity payloads in response to the speech interaction. Speech interactions may be correlated |
||||
|
* with activities via dialog-specific data in the activity payload. |
||||
|
* |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
* @param completionHandler the handler function called when keyword recognition has started. |
||||
|
*/ |
||||
|
- (void)startKeywordRecognitionAsync |
||||
|
:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
completionHandler:(nonnull SPXDialogServiceConnectorAsyncCompletionHandler)completionHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops any active keyword recognition. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether keyword recognition was stopped successfully. If NO, additional information may |
||||
|
* be available in outError. |
||||
|
*/ |
||||
|
- (BOOL)stopKeywordRecognition:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops any active keyword recognition. |
||||
|
*/ |
||||
|
- (void)stopKeywordRecognition |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops any active keyword recognition. |
||||
|
* |
||||
|
* @param completionHandler the handler function called when keyword recognition has stopped. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the request to stop was received successfully. If NO, additional error |
||||
|
* information may be available in outError. |
||||
|
*/ |
||||
|
- (BOOL)stopKeywordRecognitionAsync |
||||
|
:(nonnull SPXDialogServiceConnectorAsyncCompletionHandler)completionHandler |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops any active keyword recognition. |
||||
|
* |
||||
|
* @param completionHandler the handler function called when keyword recognition has stopped. |
||||
|
*/ |
||||
|
- (void)stopKeywordRecognitionAsync:(nonnull SPXDialogServiceConnectorAsyncCompletionHandler)completionHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Establishes a connection with the service. Connection is automatically performed when needed, but this manual call |
||||
|
* can be useful to make sure the connection is active before its first use to help reduce inital latency. |
||||
|
* |
||||
|
* Calling connect() on a DialogServiceConnector is functionally equivalent to initializing a Connection using |
||||
|
* initFromDialogServiceConnector and then calling open(false). The Connection object also provides events to monitor |
||||
|
* connections and disconnections. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether connection was successful. If NO, additional information may be available in |
||||
|
* outError. |
||||
|
*/ |
||||
|
- (BOOL)connect:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Establishes a connection with the service. Connection is automatically performed when needed, but this manual call |
||||
|
* can be useful to make sure the connection is active before its first use to help reduce inital latency. |
||||
|
* |
||||
|
* Calling connect() on a DialogServiceConnector is functionally equivalent to initializing a Connection using |
||||
|
* initFromDialogServiceConnector and then calling open(false). The Connection object also provides events to monitor |
||||
|
* connections and disconnections. |
||||
|
*/ |
||||
|
- (void)connect |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Establishes a connection with the service. Connection is automatically performed when needed, but this manual call |
||||
|
* can be useful to make sure the connection is active before its first use to help reduce inital latency. |
||||
|
* |
||||
|
* Calling connect() on a DialogServiceConnector is functionally equivalent to initializing a Connection using |
||||
|
* initFromDialogServiceConnector and then calling open(false). The Connection object also provides events to monitor |
||||
|
* connections and disconnections. |
||||
|
* |
||||
|
* @param completionHandler the handler function called when connection is complete. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the request to connect started successfully. If NO, additional information may |
||||
|
* be available in outError. |
||||
|
*/ |
||||
|
- (BOOL)connectAsync |
||||
|
:(nonnull SPXDialogServiceConnectorAsyncCompletionHandler)completionHandler |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Establishes a connection with the service. Connection is automatically performed when needed, but this manual call |
||||
|
* can be useful to make sure the connection is active before its first use to help reduce inital latency. |
||||
|
* |
||||
|
* Calling connect() on a DialogServiceConnector is functionally equivalent to initializing a Connection using |
||||
|
* initFromDialogServiceConnector and then calling open(false). The Connection object also provides events to monitor |
||||
|
* connections and disconnections. |
||||
|
* |
||||
|
* @param completionHandler the handler function called when connection is complete. |
||||
|
*/ |
||||
|
- (void)connectAsync:(nonnull SPXDialogServiceConnectorAsyncCompletionHandler)completionHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Disconnects from the service. Subsequent calls that require a connection will still automatically reconnect after |
||||
|
* manual disconnection. |
||||
|
* |
||||
|
* Calling disconnect() on a DialogServiceConnector is functionally equivalent to initializing a Connection using |
||||
|
* initFromDialogServiceConnector and then calling close(). The Connection object also provides events to monitor |
||||
|
* connections and disconnections. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether disconnection was successful. If NO, additional information may be available in |
||||
|
* outError. |
||||
|
*/ |
||||
|
- (BOOL)disconnect:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Disconnects from the service. Subsequent calls that require a connection will still automatically reconnect after |
||||
|
* manual disconnection. |
||||
|
* |
||||
|
* Calling disconnect() on a DialogServiceConnector is functionally equivalent to initializing a Connection using |
||||
|
* initFromDialogServiceConnector and then calling close(). The Connection object also provides events to monitor |
||||
|
* connections and disconnections. |
||||
|
*/ |
||||
|
- (void)disconnect |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Disconnects from the service. Subsequent calls that require a connection will still automatically reconnect after |
||||
|
* manual disconnection. |
||||
|
* |
||||
|
* Calling disconnect() on a DialogServiceConnector is functionally equivalent to initializing a Connection using |
||||
|
* initFromDialogServiceConnector and then calling close(). The Connection object also provides events to monitor |
||||
|
* connections and disconnections. |
||||
|
* |
||||
|
* @param completionHandler the handler function called when disconnection is complete. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the request to disconnect was received successfully. If NO, additional |
||||
|
* information may be available in outError. |
||||
|
*/ |
||||
|
- (BOOL)disconnectAsync |
||||
|
:(nonnull SPXDialogServiceConnectorAsyncCompletionHandler)completionHandler |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Disconnects from the service. Subsequent calls that require a connection will still automatically reconnect after |
||||
|
* manual disconnection. |
||||
|
* |
||||
|
* Calling disconnect() on a DialogServiceConnector is functionally equivalent to initializing a Connection using |
||||
|
* initFromDialogServiceConnector and then calling close(). The Connection object also provides events to monitor |
||||
|
* connections and disconnections. |
||||
|
* |
||||
|
* @param completionHandler the handler function called when disconnection is complete. |
||||
|
*/ |
||||
|
- (void)disconnectAsync:(nonnull SPXDialogServiceConnectorAsyncCompletionHandler)completionHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Registers a provided handler function to be called when a final speech-to-text-result is received by this |
||||
|
* DialogServiceConnector instance. |
||||
|
*/ |
||||
|
- (void)addRecognizedEventHandler:(nonnull SPXDialogServiceConnectorRecognitionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Registers a provided handler function to be called when an intermediate speech-to-text-result is received by this |
||||
|
* DialogServiceConnector instance. A single speech-to-text interaction may receive many intermediate 'recognizing' |
||||
|
* results that correspond to a single, final 'recognized' result. |
||||
|
*/ |
||||
|
- (void)addRecognizingEventHandler:(nonnull SPXDialogServiceConnectorRecognitionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Registers a provided handler function to be called when an interaction is abnormally terminated. This may happen for |
||||
|
* expected conditions, such as the end of provided file or audio stream input, or for unexpected error conditions. |
||||
|
* More information about the reason for the canceled event may be retrieved from the event data. |
||||
|
*/ |
||||
|
- (void)addCanceledEventHandler:(nonnull SPXDialogServiceConnectorCanceledEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Registers a provided handler function to be called when a turn status update is received from the dialog |
||||
|
* implementation that this DialogServiceConnector is connected to. |
||||
|
* A turn is a single execution session within the dialog implementation that may generate |
||||
|
* any number of activities over its course. The information in this payload represents success or failure conditions |
||||
|
* encountered by the dialog implementation over the course of this execution. This data facilitates the indication |
||||
|
* of completion or error conditions within the dialog implementation even when no explicit activity data is produced |
||||
|
* as part of a turn. |
||||
|
*/ |
||||
|
- (void)addTurnStatusReceivedEventHandler |
||||
|
:(nonnull SPXDialogServiceConnectorTurnStatusReceivedEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Registers a provided handler function to be called when an activity payload is received from the dialog |
||||
|
* implementation that this DialogServiceConnector is connected to. Activities may be sent by a dialog implementation |
||||
|
* at any time during a connection and there may be a many-to-one relationship between activities received and input, |
||||
|
* such as speech utterances, sent by this object. |
||||
|
*/ |
||||
|
- (void)addActivityReceivedEventHandler:(nonnull SPXDialogServiceConnectorActivityReceivedEventHandler)eventHandler; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,40 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXAudioStream.h" |
||||
|
|
||||
|
/**
|
||||
|
* The object type that encapsulates the response data that originates from the dialog implementation used by a |
||||
|
* DialogServiceConnector. Activities may be sent by a dialog implementation at any time during a connection and there |
||||
|
* may be a many-to-one relationship between activities received and input utterances. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXDialogServiceConnectorActivityReceivedEventArgs : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Gets a serialized JSON object that represents the activity payload sent by the dialog implementation that a |
||||
|
* DialogServiceConnector communicates with. This data is originated from the dialog implementation and both the schema |
||||
|
* and contents of the document are determined by the sender. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *activity; |
||||
|
|
||||
|
/**
|
||||
|
* Gets a value indicating whether this activity payload includes an audio stream from the text-to-speech service. If |
||||
|
* such a stream is present, it can be retrieved via the audio property. |
||||
|
* |
||||
|
* If there is no audio data associated with this activity payload, hasAudio will be false and audio will be nil. |
||||
|
*/ |
||||
|
@property (readonly)bool hasAudio; |
||||
|
|
||||
|
/**
|
||||
|
* Gets a PullAudioOutputStream associated with this activity, as produced by the text-to-speech service. This stream |
||||
|
* is populated as data arrives and may not contain all synthesized audio when the activity arrives. |
||||
|
* |
||||
|
* If there is no audio data associated with this activity payload, hasAudio will be false and audio will be nil. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)SPXPullAudioOutputStream *audio; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,39 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
|
||||
|
/**
|
||||
|
* The object type that encapsulates turn status information as received from the dialog implementation that a |
||||
|
* DialogServiceConnector communicates with. A turn is a single execution session within the dialog implementation that |
||||
|
* may generate any number of activities over its course. The information in this payload represents success or failure |
||||
|
* conditions encountered by the dialog implementation over the course of this execution. This data facilitates the |
||||
|
* indication of completion or error conditions within the dialog implementation even when no explicit activity data is |
||||
|
* produced as part of a turn. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXDialogServiceConnectorTurnStatusReceivedEventArgs : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The interaction identifier associated with this turn status event. Interaction identifiers generally correspond to a |
||||
|
* single input signal (e.g. a voice utterance or sent activity payload) and will correlate to replyTo fields within Bot |
||||
|
* Framework activities. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *interactionId; |
||||
|
|
||||
|
/**
|
||||
|
* The conversation identifier associated with this turn status event. Conversations are logical groupings of turns that |
||||
|
* may span multiple interactions. A client can use a conversation identifier to resume or retry a conversation if such |
||||
|
* a capability is supported by the backing dialog implementation. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *conversationId; |
||||
|
|
||||
|
/**
|
||||
|
* The numeric status code associated with this turn status event. These generally correspond to standard HTTP status |
||||
|
* codes such as 200 (OK), 400 (Failure/Bad Request), and 429 (Timeout/Throttled). |
||||
|
*/ |
||||
|
@property (readonly)int statusCode; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,166 @@ |
|||||
|
///
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
#import "SPXSpeechRecognitionModelInfo.h" |
||||
|
#import "SPXSpeechTranslationModelInfo.h" |
||||
|
|
||||
|
/**
|
||||
|
* Class that defines embedded (offline) speech configuration. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXEmbeddedSpeechConfiguration : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The model name for speech recognition. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable) NSString *speechRecognitionModelName; |
||||
|
|
||||
|
/**
|
||||
|
* The speech recognition output format. |
||||
|
*/ |
||||
|
@property (nonatomic) SPXOutputFormat speechRecognitionOutputFormat; |
||||
|
|
||||
|
/**
|
||||
|
* The profanity option for speech recognition. |
||||
|
*/ |
||||
|
@property (nonatomic) SPXSpeechConfigProfanityOption profanityOption; |
||||
|
|
||||
|
/**
|
||||
|
* The voice name for embedded speech synthesis. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable) NSString *speechSynthesisVoiceName; |
||||
|
|
||||
|
/**
|
||||
|
* The model name for speech translation. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable) NSString *speechTranslationModelName; |
||||
|
|
||||
|
/**
|
||||
|
* Available speech recognition models. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nonnull) NSArray<SPXSpeechRecognitionModelInfo *> *speechRecognitionModelsInfo; |
||||
|
|
||||
|
/**
|
||||
|
* Available speech translation models. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nonnull)NSArray<SPXSpeechTranslationModelInfo *> *speechTranslationModelsInfo; |
||||
|
|
||||
|
/**
|
||||
|
* Creates an instance of the embedded speech config with a specified offline model path. |
||||
|
* |
||||
|
* @param path The folder path to search for offline models. |
||||
|
* This can be a root path under which several models are located in subfolders, |
||||
|
* or a direct path to a specific model folder. |
||||
|
* @param outError The error information. |
||||
|
* @return An instance of the embedded speech config. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromPath:(nonnull NSString *)path error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Creates an instance of the embedded speech config with a specified offline model path. |
||||
|
* |
||||
|
* @param path The folder path to search for offline models. |
||||
|
* This can be a root path under which several models are located in subfolders, |
||||
|
* or a direct path to a specific model folder. |
||||
|
* @return An instance of the embedded speech config. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromPath:(nonnull NSString *)path |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Creates an instance of the embedded speech config with specified offline model paths. |
||||
|
* |
||||
|
* @param paths The folder paths to search for offline models. |
||||
|
* These can be root paths under which several models are located in subfolders, |
||||
|
* or direct paths to specific model folders. |
||||
|
* @param outError The error information. |
||||
|
* @return An instance of the embedded speech config. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromPaths:(nonnull NSArray<NSString *> *)paths error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Creates an instance of the embedded speech config with specified offline model paths. |
||||
|
* |
||||
|
* @param paths The folder paths to search for offline models. |
||||
|
* These can be root paths under which several models are located in subfolders, |
||||
|
* or direct paths to specific model folders. |
||||
|
* @return An instance of the embedded speech config. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromPaths:(nonnull NSArray<NSString *> *)paths |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Get the speech synthesis output format. |
||||
|
*/ |
||||
|
- (nonnull NSString *)speechSynthesisOutputFormat; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the speech synthesis output format (e.g. Riff16Khz16BitMonoPcm). |
||||
|
* |
||||
|
* @param format The speech synthesis output format. |
||||
|
*/ |
||||
|
- (void)setSpeechSynthesisOutputFormat:(SPXSpeechSynthesisOutputFormat)format; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the model for speech recognition. |
||||
|
* |
||||
|
* @param name The model name. |
||||
|
* @param license The license text. |
||||
|
*/ |
||||
|
- (void)setSpeechRecognitionModel:(nonnull NSString *)name license:(nonnull NSString *)license; |
||||
|
/**
|
||||
|
* Sets the voice for embedded speech synthesis. |
||||
|
* |
||||
|
* @param name The voice name of the embedded speech synthesis. |
||||
|
* @param license The license text. |
||||
|
*/ |
||||
|
- (void)setSpeechSynthesisVoice:(nonnull NSString *)name license:(nonnull NSString *)license; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the model for speech translation. |
||||
|
* |
||||
|
* @param name The model name. |
||||
|
* @param license The license text. |
||||
|
*/ |
||||
|
- (void)setSpeechTranslationModel:(nonnull NSString *)name license:(nonnull NSString *)license; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the property value. |
||||
|
* If the name is not available, it returns an empty string. |
||||
|
* |
||||
|
* @param name property name. |
||||
|
* @return value of the property. |
||||
|
*/ |
||||
|
-(nullable NSString *)getPropertyByName:(nonnull NSString *)name; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the property value by name. |
||||
|
* |
||||
|
* @param value value of the property. |
||||
|
* @param name property name. |
||||
|
*/ |
||||
|
-(void)setPropertyTo:(nonnull NSString *)value byName:(nonnull NSString *)name; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the property value. |
||||
|
* If the specified id is not available, it returns an empty string. |
||||
|
* |
||||
|
* @param propertyId property id. |
||||
|
* @return value of the property. |
||||
|
*/ |
||||
|
-(nullable NSString *)getPropertyById:(SPXPropertyId)propertyId; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the property value by property id. |
||||
|
* |
||||
|
* @param value value of the property. |
||||
|
* @param propertyId property id. |
||||
|
*/ |
||||
|
-(void)setPropertyTo:(nonnull NSString *)value byId:(SPXPropertyId)propertyId; |
||||
|
|
||||
|
@end |
||||
|
|
||||
@ -0,0 +1,77 @@ |
|||||
|
///
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
|
||||
|
/**
|
||||
|
* Class with static methods to control callback-based SDK logging. |
||||
|
* Turning on logging while running your Speech SDK scenario provides |
||||
|
* detailed information from the SDK's core native components. If you |
||||
|
* report an issue to Microsoft, you may be asked to provide logs to help |
||||
|
* Microsoft diagnose the issue. Your application should not take dependency |
||||
|
* on particular log strings, as they may change from one SDK release to another |
||||
|
* without notice. |
||||
|
* Use SPXEventLogger when you want to get access to new log strings as soon |
||||
|
* as they are available, and you need to further process them. For example, |
||||
|
* integrating Speech SDK logs with your existing logging collection system. |
||||
|
* Added in version 1.43.0 |
||||
|
* |
||||
|
* Event logging is a process wide construct. That means that if (for example) |
||||
|
* you have multiple speech recognizer objects running in parallel, you can only register |
||||
|
* one callback function to receive interleaved logs from all recognizers. You cannot register |
||||
|
* a separate callback for each recognizer. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXEventLogger : NSObject |
||||
|
|
||||
|
typedef void (^SPXEventLoggerHandler)(NSString * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* Registers a callback function that will be invoked for each new log message. |
||||
|
* |
||||
|
* @param callback The callback function to call. Pass nil to stop the Event Logger. |
||||
|
* @param outError The error information. |
||||
|
* @remarks You can only register one callback function. This call will happen on a working thread of the SDK, |
||||
|
* so the log string should be copied somewhere for further processing by another thread, and the function should return immediately. |
||||
|
* No heavy processing or network calls should be done in this callback function. |
||||
|
*/ |
||||
|
+ (void)setCallback:(nullable SPXEventLoggerHandler)callback error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Registers a callback function that will be invoked for each new log message. |
||||
|
* |
||||
|
* @param callback The callback function to call. Pass nil to stop the Event Logger. |
||||
|
* @remarks You can only register one callback function. This call will happen on a working thread of the SDK, |
||||
|
* so the log string should be copied somewhere for further processing by another thread, and the function should return immediately. |
||||
|
* No heavy processing or network calls should be done in this callback function. |
||||
|
*/ |
||||
|
+ (void)setCallback:(nullable SPXEventLoggerHandler)callback |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Sets or clears the filters that apply to file logging. |
||||
|
* |
||||
|
* @param filters Filters to use, or nil or an empty list to remove previously set filters. |
||||
|
* @param outError The error information. |
||||
|
*/ |
||||
|
+ (void)setFilters:(nullable NSArray<NSString *> *)filters error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Sets or clears the filters that apply to file logging. |
||||
|
* |
||||
|
* @param filters Filters to use, or nil or an empty list to remove previously set filters. |
||||
|
*/ |
||||
|
+ (void)setFilters:(nullable NSArray<NSString *> *)filters |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Sets the level of the messages to be captured by the logger. |
||||
|
* |
||||
|
* @param level Maximum level of detail to be captured by the logger. |
||||
|
*/ |
||||
|
+ (void)setLevel:(SPXLogLevel)level; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,99 @@ |
|||||
|
///
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
|
||||
|
/**
|
||||
|
* Class with static methods to control file-based SDK logging. |
||||
|
* Turning on logging while running your Speech SDK scenario provides |
||||
|
* detailed information from the SDK's core native components. If you |
||||
|
* report an issue to Microsoft, you may be asked to provide logs to help |
||||
|
* Microsoft diagnose the issue. Your application should not take dependency |
||||
|
* on particular log strings, as they may change from one SDK release to another |
||||
|
* without notice. |
||||
|
* SPXFileLogger is the simplest logging solution and suitable for diagnosing |
||||
|
* most on-device issues when running Speech SDK. |
||||
|
* Added in version 1.43.0 |
||||
|
* |
||||
|
* File logging is a process wide construct. That means that if (for example) |
||||
|
* you have multiple speech recognizer objects running in parallel, there will be one |
||||
|
* log file containing interleaved logs lines from all recognizers. You cannot get a |
||||
|
* separate log file for each recognizer. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXFileLogger : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Starts logging to a file. |
||||
|
* |
||||
|
* @param path Path to a log file on local disk. |
||||
|
* @param append If true, appends to existing log file. If false, creates a new log file. |
||||
|
* @param outError The error information. |
||||
|
*/ |
||||
|
+ (void)start:(nonnull NSString *)path append:(BOOL)append error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Starts logging to a file. |
||||
|
* |
||||
|
* @param path Path to a log file on local disk. |
||||
|
* @param append If true, appends to existing log file. If false, creates a new log file. |
||||
|
*/ |
||||
|
+ (void)start:(nonnull NSString *)path append:(BOOL)append |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Starts logging to a file. |
||||
|
* |
||||
|
* @param path Path to a log file on local disk. |
||||
|
* @param outError The error information. |
||||
|
*/ |
||||
|
+ (void)start:(nonnull NSString *)path error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Starts logging to a file. |
||||
|
* |
||||
|
* @param path Path to a log file on local disk. |
||||
|
*/ |
||||
|
+ (void)start:(nonnull NSString *)path |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops logging to a file. |
||||
|
* |
||||
|
* @param outError The error information. |
||||
|
*/ |
||||
|
+ (void)stop:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops logging to a file. |
||||
|
*/ |
||||
|
+ (void)stop |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Sets or clears the filters that apply to file logging. |
||||
|
* |
||||
|
* @param filters Filters to use, or nil or an empty list to remove previously set filters. |
||||
|
* @param outError The error information. |
||||
|
*/ |
||||
|
+ (void)setFilters:(nullable NSArray<NSString *> *)filters error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Sets or clears the filters that apply to file logging. |
||||
|
* |
||||
|
* @param filters Filters to use, or nil or an empty list to remove previously set filters. |
||||
|
*/ |
||||
|
+ (void)setFilters:(nullable NSArray<NSString *> *)filters |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Sets the level of the messages to be captured by the logger. |
||||
|
* |
||||
|
* @param level Maximum level of detail to be captured by the logger. |
||||
|
*/ |
||||
|
+ (void)setLevel:(SPXLogLevel)level; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,9 @@ |
|||||
|
///
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import <Foundation/Foundation.h> |
||||
|
|
||||
|
#define SPX_EXPORT __attribute__((visibility ("default"))) |
||||
|
|
||||
@ -0,0 +1,17 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents base class grammar for customizing speech recognition. |
||||
|
* |
||||
|
* Added in version 1.5.0. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXGrammar : NSObject |
||||
|
|
||||
|
@end |
||||
|
|
||||
@ -0,0 +1,23 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents a phrase that may be spoken by the user. |
||||
|
* |
||||
|
* Added in version 1.5.0. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXGrammarPhrase : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Initialize the phrase with a given text. |
||||
|
* @param value an utterance. |
||||
|
*/ |
||||
|
-(nullable instancetype) initWithText:(nonnull NSString*)value; |
||||
|
|
||||
|
@end |
||||
|
|
||||
@ -0,0 +1,46 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognitionEventArgs.h" |
||||
|
#import "SPXIntentRecognitionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload for intent recognizing/recognized events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXIntentRecognitionEventArgs : SPXRecognitionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* Represents the intent recognition result. |
||||
|
*/ |
||||
|
@property (readonly, nullable)SPXIntentRecognitionResult *result; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of intent recognition canceled result events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXIntentRecognitionCanceledEventArgs : SPXIntentRecognitionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* The reason the recognition was canceled. |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationReason reason; |
||||
|
|
||||
|
/**
|
||||
|
* The error code in case of an unsuccessful recognition (reason is set to Error). |
||||
|
* |
||||
|
* Added in version 1.1.0. |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationErrorCode errorCode; |
||||
|
|
||||
|
/**
|
||||
|
* The error message in case of an unsuccessful recognition (reason is set to Error). |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *errorDetails; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,21 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognitionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the result of intent recognition. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXIntentRecognitionResult : SPXRecognitionResult |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* A string that represents an intent identifier to be recognized. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *intentId; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,333 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechConfiguration.h" |
||||
|
#import "SPXAudioConfiguration.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
#import "SPXRecognizer.h" |
||||
|
#import "SPXLanguageUnderstandingModel.h" |
||||
|
#import "SPXIntentRecognitionResult.h" |
||||
|
#import "SPXIntentRecognitionEventArgs.h" |
||||
|
|
||||
|
/**
|
||||
|
* Performs intent recognition on speech input. It returns both recognized text and recognized intent. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXIntentRecognizer : SPXRecognizer |
||||
|
|
||||
|
typedef void (^SPXIntentRecognitionEventHandler)(SPXIntentRecognizer * _Nonnull, SPXIntentRecognitionEventArgs * _Nonnull); |
||||
|
typedef void (^SPXIntentRecognitionCanceledEventHandler)(SPXIntentRecognizer * _Nonnull, SPXIntentRecognitionCanceledEventArgs * _Nonnull); |
||||
|
typedef void (^SPXIntentRecognitionAsyncCompletionHandler)(void); |
||||
|
|
||||
|
/**
|
||||
|
* The authorization token used to communicate with the intent recognition service. |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, |
||||
|
* the caller needs to refresh it by calling this setter with a new valid token. |
||||
|
* Otherwise, the recognizer will encounter errors during recognition. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *authorizationToken; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of intent recognizer using the specified speech configuration. |
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @return an intent recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of intent recognizer using the specified speech configuration. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an intent recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of an intent recognizer using the specified speech and audio configurations. |
||||
|
* |
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return an intent recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of an intent recognizer using the specified speech and audio configurations. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an intent recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Adds a simple phrase that may be spoken by the user, indicating a specific user intent. |
||||
|
* |
||||
|
* @param simplePhrase The phrase corresponding to the intent. |
||||
|
*/ |
||||
|
- (void)addIntentFromPhrase:(nonnull NSString *)simplePhrase; |
||||
|
|
||||
|
/**
|
||||
|
* Adds a simple phrase that may be spoken by the user, indicating a specific user intent, and maps it to the provided identifier. |
||||
|
* |
||||
|
* @param simplePhrase The phrase corresponding to the intent. |
||||
|
* @param intentId A custom id string to be returned in the SPXIntentRecognitionResult's getIntentId() method. |
||||
|
*/ |
||||
|
- (void)addIntentFromPhrase:(nonnull NSString *)simplePhrase mappingToId:(nonnull NSString *)intentId; |
||||
|
|
||||
|
/**
|
||||
|
* Adds a single intent by name from the specified Language Understanding Model. |
||||
|
* |
||||
|
* @param intentName The name of the single intent to be included from the language understanding model. |
||||
|
* @param model The language understanding model containing the intent. |
||||
|
*/ |
||||
|
- (void)addIntent:(nonnull NSString *)intentName fromModel:(nonnull SPXLanguageUnderstandingModel *)model; |
||||
|
|
||||
|
/**
|
||||
|
* Adds a single intent by name from the specified Language Understanding Model, and maps the intent name to the provided identifier. |
||||
|
* |
||||
|
* @param intentName The name of the single intent to be included from the language understanding model. |
||||
|
* @param model The language understanding model containing the intent. |
||||
|
* @param intentId A custom id string to be returned in the SPXIntentRecognitionResult's getIntentId() method. |
||||
|
*/ |
||||
|
- (void)addIntent:(nonnull NSString *)intentName fromModel:(nonnull SPXLanguageUnderstandingModel *)model mappingToId:(nonnull NSString *)intentId; |
||||
|
|
||||
|
/**
|
||||
|
* Adds all intents from the specified Language Understanding Model. |
||||
|
* |
||||
|
* @param model The language understanding model containing the intents. |
||||
|
*/ |
||||
|
- (void)addAllIntentsFromModel:(nonnull SPXLanguageUnderstandingModel *)model; |
||||
|
|
||||
|
/**
|
||||
|
* Adds all intents from the specified Language Understanding Model, and maps them to the provided identifier. |
||||
|
* |
||||
|
* @param model The language understanding model containing the intents. |
||||
|
* @param intentId A custom id string to be returned in the SPXIntentRecognitionResult's getIntentId() method. |
||||
|
*/ |
||||
|
- (void)addAllIntentsFromModel:(nonnull SPXLanguageUnderstandingModel *)model mappingToId:(nonnull NSString *)intentId; |
||||
|
|
||||
|
/**
|
||||
|
* Starts intent recognition, and returns after a single utterance is recognized. The end of a |
||||
|
* single utterance is determined by listening for silence at the end or until a maximum of about 30 |
||||
|
* seconds of audio is processed. The task returns the recognition text as result. |
||||
|
* |
||||
|
* Note: Since recognizeOnce() returns only a single utterance, it is suitable only for single |
||||
|
* shot recognition like command or query. |
||||
|
* For long-running multi-utterance recognition, use startContinuousRecognitionAsync() instead. |
||||
|
* |
||||
|
* @return the result of intent recognition. |
||||
|
*/ |
||||
|
- (nonnull SPXIntentRecognitionResult *)recognizeOnce |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling.") NS_RETURNS_RETAINED; |
||||
|
|
||||
|
/**
|
||||
|
* Starts intent recognition, and returns after a single utterance is recognized. The end of a |
||||
|
* single utterance is determined by listening for silence at the end or until a maximum of about 30 |
||||
|
* seconds of audio is processed. The task returns the recognition text as result. |
||||
|
* |
||||
|
* Note: Since recognizeOnce() returns only a single utterance, it is suitable only for single |
||||
|
* shot recognition like command or query. |
||||
|
* For long-running multi-utterance recognition, use startContinuousRecognitionAsync() instead. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return the result of intent recognition. |
||||
|
*/ |
||||
|
- (nullable SPXIntentRecognitionResult *)recognizeOnce:(NSError * _Nullable * _Nullable)outError NS_RETURNS_RETAINED; |
||||
|
|
||||
|
/**
|
||||
|
* Starts speech recognition, and returns after a single utterance is recognized. The end of a |
||||
|
* single utterance is determined by listening for silence at the end or until a maximum of about 30 |
||||
|
* seconds of audio is processed. The task returns the recognition text as result. |
||||
|
* |
||||
|
* Note: Since recognizeOnceAsync() returns only a single utterance, it is suitable only for single |
||||
|
* shot recognition like command or query. |
||||
|
* For long-running multi-utterance recognition, use startContinuousRecognitionAsync() instead. |
||||
|
* |
||||
|
* @param resultReceivedHandler the block function to be called when the first utterance has been recognized. |
||||
|
*/ |
||||
|
- (void)recognizeOnceAsync:(nonnull void (^)(SPXIntentRecognitionResult * _Nonnull)) resultReceivedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Starts speech recognition, and returns after a single utterance is recognized. The end of a |
||||
|
* single utterance is determined by listening for silence at the end or until a maximum of about 30 |
||||
|
* seconds of audio is processed. The task returns the recognition text as result. |
||||
|
* Note: Since recognizeOnceAsync() returns only a single utterance, it is suitable only for single |
||||
|
* shot recognition like command or query. |
||||
|
* For long-running multi-utterance recognition, use startContinuousRecognitionAsync() instead. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param resultReceivedHandler the block function to be called when the first utterance has been recognized. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)recognizeOnceAsync:(nonnull void (^)(SPXIntentRecognitionResult * _Nonnull)) resultReceivedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Starts speech recognition on a continuous audio stream, until stopContinuousRecognition() is called. |
||||
|
* User must subscribe to events to receive recognition results. |
||||
|
*/ |
||||
|
- (void)startContinuousRecognition |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Starts speech recognition on a continuous audio stream, until stopContinuousRecognition() is called. |
||||
|
* User must subscribe to events to receive recognition results. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)startContinuousRecognition:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops continuous intent recognition. |
||||
|
*/ |
||||
|
- (void)stopContinuousRecognition |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops continuous intent recognition. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)stopContinuousRecognition:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Begins a speech-to-text interaction with this recognizer using a keyword. |
||||
|
* This interaction will use the provided keyword model to listen for a keyword indefinitely, |
||||
|
* during which audio is not sent to the speech service and all processing is performed locally. |
||||
|
* When a keyword is recognized, IntentRecognizer will automatically connect to the speech service |
||||
|
* and begin sending audio data from just before the keyword. |
||||
|
* When received, speech-to-text results may be processed by the provided result handler |
||||
|
* or retrieved via a subscription to the recognized event. |
||||
|
* |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the requested keyword recognition successfully started. If NO, outError may |
||||
|
* contain additional information. |
||||
|
*/ |
||||
|
- (BOOL)startKeywordRecognition |
||||
|
:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Begins a speech-to-text interaction with this recognizer using a keyword. |
||||
|
* This interaction will use the provided keyword model to listen for a keyword indefinitely, |
||||
|
* during which audio is not sent to the speech service and all processing is performed locally. |
||||
|
* When a keyword is recognized, IntentRecognizer will automatically connect to the speech service |
||||
|
* and begin sending audio data from just before the keyword. |
||||
|
* When received, speech-to-text results may be processed by the provided result handler |
||||
|
* or retrieved via a subscription to the recognized event. |
||||
|
* |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
*/ |
||||
|
- (void)startKeywordRecognition:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Asynchronously begins a speech-to-text interaction with this recognizer |
||||
|
* and immediately returns execution to the calling thread. |
||||
|
* This interaction will use the provided keyword model to listen for a keyword indefinitely, |
||||
|
* during which audio is not sent to the speech service and all processing is performed locally. |
||||
|
* When a keyword is recognized, IntentRecognizer will automatically connect to the speech service |
||||
|
* and begin sending audio data from just before the keyword. |
||||
|
* When received, speech-to-text results may be processed by the provided result handler |
||||
|
* or retrieved via a subscription to the recognized event. |
||||
|
* |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
* @param completionHandler the handler function called when keyword recognition has started. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the request to start keyword recognition was received successfully. If NO, |
||||
|
* additional information may available in outError. |
||||
|
*/ |
||||
|
- (BOOL)startKeywordRecognitionAsync |
||||
|
:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
completionHandler:(nonnull SPXIntentRecognitionAsyncCompletionHandler)completionHandler |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Asynchronously begins a speech-to-text interaction with this recognizer |
||||
|
* and immediately returns execution to the calling thread. |
||||
|
* This interaction will use the provided keyword model to listen for a keyword indefinitely, |
||||
|
* during which audio is not sent to the speech service and all processing is performed locally. |
||||
|
* When a keyword is recognized, IntentRecognizer will automatically connect to the speech service |
||||
|
* and begin sending audio data from just before the keyword. |
||||
|
* When received, speech-to-text results may be processed by the provided result handler |
||||
|
* or retrieved via a subscription to the recognized event. |
||||
|
* |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
* @param completionHandler the handler function called when keyword recognition has started. |
||||
|
*/ |
||||
|
- (void)startKeywordRecognitionAsync |
||||
|
:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
completionHandler:(nonnull SPXIntentRecognitionAsyncCompletionHandler)completionHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops any active keyword recognition. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether keyword recognition was stopped successfully. If NO, additional information may |
||||
|
* be available in outError. |
||||
|
*/ |
||||
|
- (BOOL)stopKeywordRecognition:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops any active keyword recognition. |
||||
|
*/ |
||||
|
- (void)stopKeywordRecognition |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops any active keyword recognition. |
||||
|
* |
||||
|
* @param completionHandler the handler function called when keyword recognition has stopped. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the request to stop was received successfully. If NO, additional error |
||||
|
* information may be available in outError. |
||||
|
*/ |
||||
|
- (BOOL)stopKeywordRecognitionAsync |
||||
|
:(nonnull SPXIntentRecognitionAsyncCompletionHandler)completionHandler |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops any active keyword recognition. |
||||
|
* |
||||
|
* @param completionHandler the handler function called when keyword recognition has stopped. |
||||
|
*/ |
||||
|
- (void)stopKeywordRecognitionAsync:(nonnull SPXIntentRecognitionAsyncCompletionHandler)completionHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Recognized event which indicates that a final result has been recognized. |
||||
|
*/ |
||||
|
- (void)addRecognizedEventHandler:(nonnull SPXIntentRecognitionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Recognizing event which indicates that an intermediate result has been recognized. |
||||
|
*/ |
||||
|
- (void)addRecognizingEventHandler:(nonnull SPXIntentRecognitionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Canceled event which indicates that an error occurred during recognition. |
||||
|
*/ |
||||
|
- (void)addCanceledEventHandler:(nonnull SPXIntentRecognitionCanceledEventHandler)eventHandler; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,30 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognitionEventArgs.h" |
||||
|
#import "SPXSpeechRecognitionEventArgs.h" |
||||
|
#import "SPXKeywordRecognitionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload for keyword recognizing/recognized events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXKeywordRecognitionEventArgs : SPXRecognitionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* Represents the keyword recognition result. |
||||
|
*/ |
||||
|
@property (readonly, nullable)SPXKeywordRecognitionResult *result; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of keyword recognition canceled events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXKeywordRecognitionCanceledEventArgs : SPXSpeechRecognitionCanceledEventArgs |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,32 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents keyword recognition model used with StartKeywordRecognitionAsync methods. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXKeywordRecognitionModel : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Creates a keyword recognition model using the specified file. |
||||
|
* |
||||
|
* @param fileName The file name of the keyword recognition model. |
||||
|
* @return an instance of keyword recognition model. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromFile:(nonnull NSString *)fileName |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Creates a keyword recognition model using the specified file. |
||||
|
* |
||||
|
* @param fileName The file name of the keyword recognition model. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of keyword recognition model. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromFile:(nonnull NSString *)fileName error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,15 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognitionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the result of keyword recognition. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXKeywordRecognitionResult : SPXRecognitionResult |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,101 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXAudioConfiguration.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
#import "SPXRecognizer.h" |
||||
|
#import "SPXKeywordRecognitionModel.h" |
||||
|
#import "SPXKeywordRecognitionResult.h" |
||||
|
#import "SPXKeywordRecognitionEventArgs.h" |
||||
|
|
||||
|
/**
|
||||
|
* Recognizer type that is specialized to only handle keyword activation. |
||||
|
* |
||||
|
* Added in version 1.15.0. |
||||
|
* |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXKeywordRecognizer : NSObject |
||||
|
|
||||
|
typedef void (^SPXKeywordRecognitionEventHandler)(SPXKeywordRecognizer * _Nonnull, SPXKeywordRecognitionEventArgs * _Nonnull); |
||||
|
typedef void (^SPXKeywordRecognitionCanceledEventHandler)(SPXKeywordRecognizer * _Nonnull, SPXKeywordRecognitionCanceledEventArgs * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* The collection of properties and their values defined for this SPXKeywordRecognizer. |
||||
|
*/ |
||||
|
@property (readonly, nullable)id <SPXPropertyCollection> properties; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of keyword recognizer using the specified audio configuration. |
||||
|
* |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return an keyword recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of keyword recognizer using the specified audio configuration. |
||||
|
* |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an keyword recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXAudioConfiguration *)audioConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Starts a keyword recognition session. This session will last until the first keyword is recognized. |
||||
|
* When this happens, a Recognized event will be raised and the session will end. To rearm the keyword, |
||||
|
* the method needs to be called again after the event is emitted. |
||||
|
* |
||||
|
* Note that if no keyword is detected in the input, the task will never resolve (unless stopRecognitionAsync method is called). |
||||
|
* |
||||
|
* @param resultReceivedHandler the block function to be called when the keyword has been recognized. |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
*/ |
||||
|
- (void)recognizeOnceAsync:(nonnull void (^)(SPXKeywordRecognitionResult * _Nonnull)) resultReceivedHandler keywordModel:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Starts a keyword recognition session. This session will last until the first keyword is recognized. |
||||
|
* When this happens, a Recognized event will be raised and the session will end. To rearm the keyword, |
||||
|
* the method needs to be called again after the event is emitted. |
||||
|
* |
||||
|
* Note that if no keyword is detected in the input, the task will never resolve (unless stopRecognitionAsync method is called). |
||||
|
* |
||||
|
* @param resultReceivedHandler the block function to be called when the keyword has been recognized. |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)recognizeOnceAsync:(nonnull void (^)(SPXKeywordRecognitionResult * _Nonnull)) resultReceivedHandler keywordModel:(nonnull SPXKeywordRecognitionModel *)keywordModel error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops a currently active keyword recognition session. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)stopRecognitionAsync:(nonnull void (^)(BOOL stopped, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops a currently active keyword recognition session. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)stopRecognitionAsync:(nonnull void (^)(BOOL stopped, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Recognized event which indicates that a final result has been recognized. |
||||
|
*/ |
||||
|
- (void)addRecognizedEventHandler:(nonnull SPXKeywordRecognitionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Canceled event which indicates that an error occurred during recognition. |
||||
|
*/ |
||||
|
- (void)addCanceledEventHandler:(nonnull SPXKeywordRecognitionCanceledEventHandler)eventHandler; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,44 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents the language understanding model used for intent recognition. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXLanguageUnderstandingModel : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a language understanding model using the specified endpoint URL. |
||||
|
* |
||||
|
* The Speech SDK only supports LUIS v2.0 endpoints. |
||||
|
* |
||||
|
* For details, see [Quickstart: Recognize intents with the Speech service and LUIS](/azure/cognitive-services/Speech-Service/get-started-intent-recognition?pivots=programming-language-objectivec). |
||||
|
* |
||||
|
* @param uri the endpoint of the language understanding model. |
||||
|
* @return an instance of language understanding model. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEndpoint:(nonnull NSString *)uri; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a language understanding model using an application id for the Language Understanding service. |
||||
|
* |
||||
|
* @param appId the application id for the Language Understanding service. |
||||
|
* @return an instance of language understanding model. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAppId:(nonnull NSString *)appId; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a language understanding model using a subscription key, application id and region for the Language Understanding service. |
||||
|
* |
||||
|
* @param key the subscription key for the Language Understanding service. |
||||
|
* @param appId the application id for the Language Understanding service. |
||||
|
* @param region the region for the Language Understanding service (see the <a href="https://aka.ms/csspeech/region">region page</a>). |
||||
|
* @return an instance of language understanding model. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSubscription:(nonnull NSString *)key withAppId:(nonnull NSString *)appId andRegion:(nonnull NSString *)region; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,327 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXUser.h" |
||||
|
#import "SPXParticipant.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
#import "SPXSpeechConfiguration.h" |
||||
|
|
||||
|
/**
|
||||
|
* Performs meeting management including add and remove participants. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXMeeting : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The collection of properties and their values defined for this SPXMeeting. |
||||
|
*/ |
||||
|
@property (readonly, nullable)id <SPXPropertyCollection> properties; |
||||
|
|
||||
|
/**
|
||||
|
* The unique identifier for the meeting. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *meetingId; |
||||
|
|
||||
|
/**
|
||||
|
* The authorization token used to communicate with the service. |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, |
||||
|
* the caller needs to refresh it by calling this setter with a new valid token. Otherwise, the recognizer will |
||||
|
* encounter errors during recognition. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *authorizationToken; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of meeting using the specified speech configuration. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration. |
||||
|
* @return a meeting instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of meeting using the specified speech configuration and meeting id. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration. |
||||
|
* @param meetingId a unqiue identification of your meeting. |
||||
|
* @return a meeting instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration meetingId:(nonnull NSString *)meetingId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of meeting using the specified speech configuration and meeting id. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration. |
||||
|
* @param meetingId a unqiue identification of your meeting. |
||||
|
* @param outError error information. |
||||
|
* @return a meeting instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration meetingId:(nonnull NSString *)meetingId error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Starts a meeting, and provides asynchronous callback with the information is meeting started successfully or not. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)startMeetingAsync:(nonnull void (^)(BOOL started, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Starts a meeting, and provides asynchronous callback with the information is meeting started successfully or not. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)startMeetingAsync:(nonnull void (^)(BOOL started, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Ends a meeting, and provides asynchronous callback with the information is meeting ended successfully or not. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)endMeetingAsync:(nonnull void (^)(BOOL ended, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Ends a meeting, and provides asynchronous callback with the information is meeting ended successfully or not. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)endMeetingAsync:(nonnull void (^)(BOOL ended, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Deletes a meeting, and provides asynchronous callback with the information is meeting deletion completed. |
||||
|
* After deleted, no one will be able to join the meeting. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)deleteMeetingAsync:(nonnull void (^)(BOOL deleted, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Deletes a meeting, and provides asynchronous callback with the information is meeting deletion completed. |
||||
|
* After deleted, no one will be able to join the meeting. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)deleteMeetingAsync:(nonnull void (^)(BOOL deleted, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Locks a meeting, and provides asynchronous callback with the information is meeting locking completed. |
||||
|
* After locked, new participants are prevented from joining the meeting. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)lockMeetingAsync:(nonnull void (^)(BOOL locked, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Locks a meeting, and provides asynchronous callback with the information is meeting locking completed. |
||||
|
* After locked, new participants are prevented from joining the meeting. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)lockMeetingAsync:(nonnull void (^)(BOOL locked, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Unlocks a meeting, and provides asynchronous callback with the information is meeting unlocking completed. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)unlockMeetingAsync:(nonnull void (^)(BOOL unlocked, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Unlocks a meeting, and provides asynchronous callback with the information is meeting unlocking completed. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)unlockMeetingAsync:(nonnull void (^)(BOOL unlocked, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Mute all other participants in the meeting. After this no other participants will have their speech recognitions broadcast, |
||||
|
* nor be able to send text messages. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)muteAllParticipantsAsync:(nonnull void (^)(BOOL muted, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Mute all other participants in the meeting. After this no other participants will have their speech recognitions broadcast, |
||||
|
* nor be able to send text messages. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)muteAllParticipantsAsync:(nonnull void (^)(BOOL muted, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Unmute all other participants in the meeting. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)unmuteAllParticipantsAsync:(nonnull void (^)(BOOL unmuted, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Unmute all other participants in the meeting. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)unmuteAllParticipantsAsync:(nonnull void (^)(BOOL unmuted, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Mute participant with a given userId in the meeting. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
*/ |
||||
|
- (void)muteParticipantAsync:(nonnull void (^)(BOOL muted, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Mute participant with a given userId in the meeting. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)muteParticipantAsync:(nonnull void (^)(BOOL muted, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Unmute participant with a given userId in the meeting. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
*/ |
||||
|
- (void)unmuteParticipantAsync:(nonnull void (^)(BOOL unmuted, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Unmute participant with a given userId in the meeting. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)unmuteParticipantAsync:(nonnull void (^)(BOOL unmuted, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Adds a participant from a meeting using a user id. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
*/ |
||||
|
- (void)addParticipantAsync:(nonnull void (^)(SPXParticipant * _Nullable, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Adds a participant from a meeting using a user id. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)addParticipantAsync:(nonnull void (^)(SPXParticipant * _Nullable, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Adds a participant from a meeting using a Participant object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param participant A Participant instance. |
||||
|
*/ |
||||
|
- (void)addParticipantAsync:(nonnull void (^)(SPXParticipant * _Nullable, NSError * _Nullable))completedHandler participant:(nonnull SPXParticipant *)participant |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Adds a participant from a meeting using a Participant object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param participant A Participant instance. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)addParticipantAsync:(nonnull void (^)(SPXParticipant * _Nullable, NSError * _Nullable))completedHandler participant:(nonnull SPXParticipant *)participant error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Adds a participant from a meeting using a User object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param user A User instance. |
||||
|
*/ |
||||
|
- (void)addParticipantAsync:(nonnull void (^)(SPXUser * _Nullable, NSError * _Nullable))completedHandler user:(nonnull SPXUser *)user |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Adds a participant from a meeting using a User object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param user A User instance. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)addParticipantAsync:(nonnull void (^)(SPXUser * _Nullable, NSError * _Nullable))completedHandler user:(nonnull SPXUser *)user error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Remove a participant from a meeting using a user id. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
*/ |
||||
|
- (void)removeParticipantAsync:(nonnull void (^)(BOOL removed, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Remove a participant from a meeting using a user id. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param userId A user identifier. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)removeParticipantAsync:(nonnull void (^)(BOOL removed, NSError * _Nullable))completedHandler userId:(nonnull NSString *)userId error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Remove a participant from a meeting using a Participant object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param participant A Participant instance. |
||||
|
*/ |
||||
|
- (void)removeParticipantAsync:(nonnull void (^)(BOOL removed, NSError * _Nullable))completedHandler participant:(nonnull SPXParticipant *)participant |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Remove a participant from a meeting using a Participant object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param participant A Participant instance. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)removeParticipantAsync:(nonnull void (^)(BOOL removed, NSError * _Nullable))completedHandler participant:(nonnull SPXParticipant *)participant error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Remove a participant from a meeting using a User object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param user A User instance. |
||||
|
*/ |
||||
|
- (void)removeParticipantAsync:(nonnull void (^)(BOOL removed, NSError * _Nullable))completedHandler user:(nonnull SPXUser *)user |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Remove a participant from a meeting using a User object. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param user A User instance. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)removeParticipantAsync:(nonnull void (^)(BOOL removed, NSError * _Nullable))completedHandler user:(nonnull SPXUser *)user error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,153 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechConfiguration.h" |
||||
|
#import "SPXAudioConfiguration.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
#import "SPXRecognizer.h" |
||||
|
#import "SPXMeeting.h" |
||||
|
#import "SPXMeetingTranscriptionResult.h" |
||||
|
#import "SPXMeetingTranscriptionEventArgs.h" |
||||
|
|
||||
|
/**
|
||||
|
* Performs meeting transcribing for audio input streams, and gets transcribed text and user id as a result. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXMeetingTranscriber : SPXRecognizer |
||||
|
|
||||
|
typedef void (^SPXMeetingTranscriptionEventHandler)(SPXMeetingTranscriber * _Nonnull, SPXMeetingTranscriptionEventArgs * _Nonnull); |
||||
|
typedef void (^SPXMeetingTranscriptionCanceledEventHandler)(SPXMeetingTranscriber * _Nonnull, SPXMeetingTranscriptionCanceledEventArgs * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* The authorization token used to communicate with the meeting transcription service. |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, |
||||
|
* the caller needs to refresh it by calling this setter with a new valid token. |
||||
|
* Otherwise, the recognizer will encounter errors during recognition. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *authorizationToken; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of a meeting transcriber using the default configuration. |
||||
|
* @return a meeting transcriber instance. |
||||
|
*/ |
||||
|
#pragma clang diagnostic push |
||||
|
#pragma clang diagnostic ignored "-Wnullability" |
||||
|
- (nullable instancetype)init |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
#pragma clang diagnostic pop |
||||
|
/**
|
||||
|
* Initializes a new instance of a meeting transcriber using the default configuration. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return a meeting transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of a meeting transcriber using the specified audio configuration. |
||||
|
* |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return a meeting transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAudioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of a meeting transcriber using the specified audio configuration. |
||||
|
* |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return a meeting transcriber instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAudioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Join a meeting. |
||||
|
* A meeting transcriber must join a meeting before transcribing audio. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param meeting speech configuration. |
||||
|
*/ |
||||
|
- (void)joinMeetingAsync:(nonnull void (^)(BOOL joined, NSError * _Nullable))completedHandler meeting:(nonnull SPXMeeting *)meeting |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Join a meeting. |
||||
|
* A meeting transcriber must join a meeting before transcribing audio. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param meeting speech configuration. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)joinMeetingAsync:(nonnull void (^)(BOOL joined, NSError * _Nullable))completedHandler meeting:(nonnull SPXMeeting *)meeting error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Leave a meeting. |
||||
|
* After leaving a meeting, no transcribing and transcribed events will be sent out. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)leaveMeetingAsync:(nonnull void (^)(BOOL left, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Leave a meeting. |
||||
|
* After leaving a meeting, no transcribing and transcribed events will be sent out. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)leaveMeetingAsync:(nonnull void (^)(BOOL left, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Starts meeting transcribing on a continuous audio stream, until stopTranscribingAsync() is called. |
||||
|
* User must subscribe to events to receive transcription results. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)startTranscribingAsync:(nonnull void (^)(BOOL started, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Starts meeting transcribing on a continuous audio stream, until stopTranscribingAsync() is called. |
||||
|
* User must subscribe to events to receive transcription results. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)startTranscribingAsync:(nonnull void (^)(BOOL started, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops meeting transcribing. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
*/ |
||||
|
- (void)stopTranscribingAsync:(nonnull void (^)(BOOL stopped, NSError * _Nullable))completedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops meeting transcribing. |
||||
|
* |
||||
|
* @param completedHandler the block function to be called when async operation has been completed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)stopTranscribingAsync:(nonnull void (^)(BOOL stopped, NSError * _Nullable))completedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Transcribed event which indicates that a final result has been transcribed. |
||||
|
*/ |
||||
|
- (void)addTranscribedEventHandler:(nonnull SPXMeetingTranscriptionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Transcribing event which indicates an that intermediate result has been transcribed. |
||||
|
*/ |
||||
|
- (void)addTranscribingEventHandler:(nonnull SPXMeetingTranscriptionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Canceled event which indicates that an error occurred during transcription. |
||||
|
*/ |
||||
|
- (void)addCanceledEventHandler:(nonnull SPXMeetingTranscriptionCanceledEventHandler)eventHandler; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,45 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognitionEventArgs.h" |
||||
|
#import "SPXMeetingTranscriptionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload for meeting transcription events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXMeetingTranscriptionEventArgs : SPXRecognitionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* Represents the meeting transcription result. |
||||
|
*/ |
||||
|
@property (readonly, nullable)SPXMeetingTranscriptionResult *result; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of meeting transcription canceled result events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXMeetingTranscriptionCanceledEventArgs : SPXMeetingTranscriptionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* The reason the trancription was canceled. |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationReason reason; |
||||
|
|
||||
|
/**
|
||||
|
* The error code in case of an unsuccessful transcription (reason is set to Error). |
||||
|
* |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationErrorCode errorCode; |
||||
|
|
||||
|
/**
|
||||
|
* The error message in case of an unsuccessful transcription (reason is set to Error). |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *errorDetails; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,25 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognitionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the result of meeting transcription. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXMeetingTranscriptionResult : SPXRecognitionResult |
||||
|
|
||||
|
/**
|
||||
|
* A string that represents an user identifier in the meeting. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *userId; |
||||
|
|
||||
|
/**
|
||||
|
* A string that represents the utterance. This id is consistence for intermediates and final speech recognition result from one speaker. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *utteranceId; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,127 @@ |
|||||
|
///
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
|
||||
|
/**
|
||||
|
* Class with static methods to control SDK logging into an in-memory buffer. |
||||
|
* Turning on logging while running your Speech SDK scenario provides |
||||
|
* detailed information from the SDK's core native components. If you |
||||
|
* report an issue to Microsoft, you may be asked to provide logs to help |
||||
|
* Microsoft diagnose the issue. Your application should not take dependency |
||||
|
* on particular log strings, as they may change from one SDK release to another |
||||
|
* without notice. |
||||
|
* SPXMemoryLogger is designed for the case where you want to get access to logs |
||||
|
* that were taken in the short duration before some unexpected event happens. |
||||
|
* For example, if you are running a Speech Recognizer, you may want to dump the SPXMemoryLogger |
||||
|
* after getting an event indicating recognition was canceled due to some error. |
||||
|
* The size of the memory buffer is fixed at 2MB and cannot be changed. This is |
||||
|
* a "ring" buffer, that is, new log strings written replace the oldest ones |
||||
|
* in the buffer. |
||||
|
* Added in version 1.43.0 |
||||
|
* |
||||
|
* Memory logging is a process wide construct. That means that if (for example) |
||||
|
* you have multiple speech recognizer objects running in parallel, there will be one |
||||
|
* memory buffer containing interleaved logs from all recognizers. You cannot get a |
||||
|
* separate logs for each recognizer. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXMemoryLogger : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Starts logging into the internal memory buffer. |
||||
|
*/ |
||||
|
+ (void)start; |
||||
|
|
||||
|
/**
|
||||
|
* Stops logging into the internal memory buffer. |
||||
|
*/ |
||||
|
+ (void)stop; |
||||
|
|
||||
|
/**
|
||||
|
* Sets or clears the filters that apply to file logging. |
||||
|
* |
||||
|
* @param filters Filters to use, or nil or an empty list to remove previously set filters. |
||||
|
* @param outError The error information. |
||||
|
*/ |
||||
|
+ (void)setFilters:(nullable NSArray<NSString *> *)filters error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Sets or clears the filters that apply to file logging. |
||||
|
* |
||||
|
* @param filters Filters to use, or nil or an empty list to remove previously set filters. |
||||
|
*/ |
||||
|
+ (void)setFilters:(nullable NSArray<NSString *> *)filters |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Writes the content of the whole memory buffer to the specified file. |
||||
|
* It does not block other SDK threads from continuing to log into the buffer. |
||||
|
* |
||||
|
* @param path Path to a log file on local disk. |
||||
|
* @remarks This does not reset (clear) the memory buffer. |
||||
|
*/ |
||||
|
+ (void)dumpToFile:(nonnull NSString *)path |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Writes the content of the whole memory buffer to the specified file. |
||||
|
* It does not block other SDK threads from continuing to log into the buffer. |
||||
|
* |
||||
|
* @param path Path to a log file on local disk. |
||||
|
* @param outError The error information. |
||||
|
* @remarks This does not reset (clear) the memory buffer. |
||||
|
*/ |
||||
|
+ (void)dumpToFile:(nonnull NSString *)path error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Writes the content of the whole memory buffer to the specified output stream. |
||||
|
* It does not block other SDK threads from continuing to log into the buffer. |
||||
|
* |
||||
|
* @param outputStream The output stream to write to. |
||||
|
* @remarks This does not reset (clear) the memory buffer. |
||||
|
*/ |
||||
|
+ (void)dumpToOutputStream:(nonnull NSOutputStream *)outputStream |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Writes the content of the whole memory buffer to the specified output stream. |
||||
|
* It does not block other SDK threads from continuing to log into the buffer. |
||||
|
* |
||||
|
* @param outputStream The output stream to write to. |
||||
|
* @param outError The error information. |
||||
|
* @remarks This does not reset (clear) the memory buffer. |
||||
|
*/ |
||||
|
+ (void)dumpToOutputStream:(nonnull NSOutputStream *)outputStream error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the content of the whole memory buffer as an array of strings. |
||||
|
* It does not block other SDK threads from continuing to log into the buffer. |
||||
|
* |
||||
|
* @returns An array with the contents of the memory buffer copied into it. |
||||
|
* @remarks This does not reset (clear) the memory buffer. |
||||
|
*/ |
||||
|
+ (nullable NSArray<NSString *> *)dumpToNSArray |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Returns the content of the whole memory buffer as an array of strings. |
||||
|
* It does not block other SDK threads from continuing to log into the buffer. |
||||
|
* |
||||
|
* @returns An array with the contents of the memory buffer copied into it. |
||||
|
* @param outError The error information. |
||||
|
* @remarks This does not reset (clear) the memory buffer. |
||||
|
*/ |
||||
|
+ (nullable NSArray<NSString *> *)dumpToNSArray:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the level of the messages to be captured by the logger. |
||||
|
* |
||||
|
* @param level Maximum level of detail to be captured by the logger. |
||||
|
*/ |
||||
|
+ (void)setLevel:(SPXLogLevel)level; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,126 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents a participant in a conversation transcribing session. |
||||
|
* |
||||
|
* Added in version 1.13.0. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXParticipant : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The collection of properties and their values defined for this SPXParticipant. |
||||
|
*/ |
||||
|
@property (readonly, nullable)id <SPXPropertyCollection> properties; |
||||
|
|
||||
|
/**
|
||||
|
* The unique identifier for the participant. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *id; |
||||
|
|
||||
|
/**
|
||||
|
* The user's avatar as an HTML hex string (e.g. FF0000 for red). |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *avatar; |
||||
|
|
||||
|
/**
|
||||
|
* The participant's display name. Please note that each participant within the same conversation must |
||||
|
* have a different display name. Duplicate names within the same conversation are not allowed. You can |
||||
|
* use the id property as another way to refer to each participant. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *displayName; |
||||
|
|
||||
|
/**
|
||||
|
* The participant's preferred spoken language. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *preferredLanguage; |
||||
|
|
||||
|
/**
|
||||
|
* The participant's voice signature. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *voiceSignature; |
||||
|
|
||||
|
/**
|
||||
|
* Provides information is Participant muted. |
||||
|
*/ |
||||
|
@property (nonatomic, readonly)BOOL isMuted; |
||||
|
|
||||
|
/**
|
||||
|
* Provides information is participant using Text To Speech (TTS). |
||||
|
*/ |
||||
|
@property (nonatomic, readonly)BOOL isUsingTts; |
||||
|
|
||||
|
/**
|
||||
|
* Provides information is participant host. |
||||
|
*/ |
||||
|
@property (nonatomic, readonly)BOOL isHost; |
||||
|
|
||||
|
/**
|
||||
|
* Create a Participant using user id, her/his preferred language and her/his voice signature. |
||||
|
* If voice signature is empty then user will not be identified. |
||||
|
* |
||||
|
* @param userId user's Id. |
||||
|
* @param preferredLanguage users' preferred language. |
||||
|
* @param voiceSignature user's voice signature. |
||||
|
* @return The Participant object. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFrom:(nonnull NSString *)userId preferredLanguage:(nonnull NSString *)preferredLanguage voiceSignature:(nonnull NSString *)voiceSignature |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Create a Participant using user id, her/his preferred language and her/his voice signature. |
||||
|
* If voice signature is empty then user will not be identified. |
||||
|
* |
||||
|
* @param userId user's Id. |
||||
|
* @param preferredLanguage users' preferred language. |
||||
|
* @param voiceSignature user's voice signature. |
||||
|
* @return The Participant object. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFrom:(nonnull NSString *)userId preferredLanguage:(nonnull NSString *)preferredLanguage voiceSignature:(nonnull NSString *)voiceSignature error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Create a Participant using user id and her/his preferred language. |
||||
|
* |
||||
|
* @param userId user's Id. |
||||
|
* @param preferredLanguage users' preferred language. |
||||
|
* @return The Participant object. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFrom:(nonnull NSString *)userId preferredLanguage:(nonnull NSString *)preferredLanguage |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Create a Participant using user id and her/his preferred language. |
||||
|
* |
||||
|
* @param userId user's Id. |
||||
|
* @param preferredLanguage users' preferred language. |
||||
|
* @return The Participant object. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFrom:(nonnull NSString *)userId preferredLanguage:(nonnull NSString *)preferredLanguage error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Create a Participant using user id. |
||||
|
* |
||||
|
* @param userId user's Id. |
||||
|
* @return The Participant object. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFrom:(nonnull NSString *)userId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Create a Participant using user id. |
||||
|
* |
||||
|
* @param userId user's Id. |
||||
|
* @return The Participant object. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFrom:(nonnull NSString *)userId error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,38 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXGrammar.h" |
||||
|
#import "SPXRecognizer.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents a phrase list grammar for dynamic grammar scenarios. |
||||
|
* |
||||
|
* Added in version 1.5.0. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXPhraseListGrammar : SPXGrammar |
||||
|
|
||||
|
/**
|
||||
|
* Creates a phrase list grammar for the specified recognizer. |
||||
|
* |
||||
|
* @param recognizer The recognizer from which to obtain the phrase list grammar. |
||||
|
* @return a phrase list grammar instance. |
||||
|
*/ |
||||
|
-(nullable instancetype)initWithRecognizer:(nonnull SPXRecognizer *)recognizer; |
||||
|
|
||||
|
/**
|
||||
|
* Adds a simple phrase that may be spoken by the user. |
||||
|
* |
||||
|
* @param phrase The phrase to be added. |
||||
|
*/ |
||||
|
-(void)addPhrase:(nonnull NSString *)phrase; |
||||
|
|
||||
|
/**
|
||||
|
* Clears all phrases from the phrase list grammar. |
||||
|
*/ |
||||
|
-(void)clear; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,192 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
#import "SPXRecognizer.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents pronunciation assessment configuration |
||||
|
* Added in version 1.14.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXPronunciationAssessmentConfiguration : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the SPXPronunciationAssessmentConfiguration. |
||||
|
* For parameter details, see the table |
||||
|
* [Pronunciation assessment parameters](/azure/cognitive-services/speech-service/rest-speech-to-text-short#pronunciation-assessment-parameters). |
||||
|
* |
||||
|
* @param referenceText The reference text. |
||||
|
* @param gradingSystem The point system for score calibration. |
||||
|
* @param granularity The evaluation granularity. |
||||
|
* @param enableMiscue If enables miscue calculation. When true, the pronounced words are compared to the reference text, and are marked with omission/insertion based on the comparison; when false, the recognized text will always be reference text. |
||||
|
* |
||||
|
* @return an instance of pronunciation assessment configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull NSString *)referenceText |
||||
|
gradingSystem:(SPXPronunciationAssessmentGradingSystem)gradingSystem |
||||
|
granularity:(SPXPronunciationAssessmentGranularity)granularity |
||||
|
enableMiscue:(BOOL)enableMiscue |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the SPXPronunciationAssessmentConfiguration. |
||||
|
* For parameter details, see the table |
||||
|
* [Pronunciation assessment parameters](/azure/cognitive-services/speech-service/rest-speech-to-text-short#pronunciation-assessment-parameters). |
||||
|
* |
||||
|
* @param referenceText The reference text. |
||||
|
* @param gradingSystem The point system for score calibration. |
||||
|
* @param granularity The evaluation granularity. |
||||
|
* @param enableMiscue If enables miscue calculation. |
||||
|
* @param outError error information. |
||||
|
* |
||||
|
* @return an instance of pronunciation assessment configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull NSString *)referenceText |
||||
|
gradingSystem:(SPXPronunciationAssessmentGradingSystem)gradingSystem |
||||
|
granularity:(SPXPronunciationAssessmentGranularity)granularity |
||||
|
enableMiscue:(BOOL)enableMiscue |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the SPXPronunciationAssessmentConfiguration. |
||||
|
* For parameter details, see the table |
||||
|
* [Pronunciation assessment parameters](/azure/cognitive-services/speech-service/rest-speech-to-text-short#pronunciation-assessment-parameters). |
||||
|
* |
||||
|
* @param referenceText The reference text. |
||||
|
* @param gradingSystem The point system for score calibration. |
||||
|
* @param granularity The evaluation granularity. |
||||
|
* |
||||
|
* @return an instance of pronunciation assessment configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull NSString *)referenceText |
||||
|
gradingSystem:(SPXPronunciationAssessmentGradingSystem)gradingSystem |
||||
|
granularity:(SPXPronunciationAssessmentGranularity)granularity |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the SPXPronunciationAssessmentConfiguration. |
||||
|
* For parameter details, see the table |
||||
|
* [Pronunciation assessment parameters](/azure/cognitive-services/speech-service/rest-speech-to-text-short#pronunciation-assessment-parameters). |
||||
|
* |
||||
|
* @param referenceText The reference text. |
||||
|
* @param gradingSystem The point system for score calibration. |
||||
|
* @param granularity The evaluation granularity. |
||||
|
* @param outError error information. |
||||
|
* |
||||
|
* @return an instance of pronunciation assessment configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull NSString *)referenceText |
||||
|
gradingSystem:(SPXPronunciationAssessmentGradingSystem)gradingSystem |
||||
|
granularity:(SPXPronunciationAssessmentGranularity)granularity |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the SPXPronunciationAssessmentConfiguration. |
||||
|
* For parameter details, see the table |
||||
|
* [Pronunciation assessment parameters](/azure/cognitive-services/speech-service/rest-speech-to-text-short#pronunciation-assessment-parameters). |
||||
|
* |
||||
|
* @param referenceText The reference text. |
||||
|
* |
||||
|
* @return an instance of pronunciation assessment configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull NSString *)referenceText |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the SPXPronunciationAssessmentConfiguration. |
||||
|
* For parameter details, see the table |
||||
|
* [Pronunciation assessment parameters](/azure/cognitive-services/speech-service/rest-speech-to-text-short#pronunciation-assessment-parameters). |
||||
|
* |
||||
|
* @param referenceText The reference text. |
||||
|
* @param outError error information. |
||||
|
* |
||||
|
* @return an instance of pronunciation assessment configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull NSString *)referenceText |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the SPXPronunciationAssessmentConfiguration using json string. |
||||
|
* |
||||
|
* @param json the json string. |
||||
|
* |
||||
|
* @return an instance of pronunciation assessment configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithJson:(nonnull NSString *)json |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the SPXPronunciationAssessmentConfiguration using json string. |
||||
|
* |
||||
|
* @param json the json string. |
||||
|
* @param outError error information. |
||||
|
* |
||||
|
* @return an instance of pronunciation assessment configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithJson:(nonnull NSString *)json |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* The reference text. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *referenceText; |
||||
|
|
||||
|
/**
|
||||
|
* The phoneme alphabet. Valid values are "SAPI" (default) and "IPA". |
||||
|
* |
||||
|
* NOTE: Added in version 1.20.0 |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *phonemeAlphabet; |
||||
|
- (nullable NSString *)phonemeAlphabet UNAVAILABLE_ATTRIBUTE; |
||||
|
|
||||
|
/**
|
||||
|
* The nbest phoneme count. |
||||
|
* |
||||
|
* NOTE: Added in version 1.20.0 |
||||
|
*/ |
||||
|
@property (nonatomic)NSInteger nbestPhonemeCount; |
||||
|
- (NSInteger)nbestPhonemeCount UNAVAILABLE_ATTRIBUTE; |
||||
|
|
||||
|
/**
|
||||
|
* Whether to enable prosoody assessment. |
||||
|
* |
||||
|
* Added in version 1.33.0. |
||||
|
*/ |
||||
|
- (void)enableProsodyAssessment; |
||||
|
|
||||
|
/**
|
||||
|
* Enables content assessment with specific topic. |
||||
|
* |
||||
|
* Added in version 1.33.0. |
||||
|
*/ |
||||
|
- (void)enableContentAssessmentWithTopic:(nonnull NSString *)topic; |
||||
|
|
||||
|
/**
|
||||
|
* Gets the json string of pronunciation assessment parameters. |
||||
|
* |
||||
|
* @return json string of pronunciation assessment parameters. |
||||
|
*/ |
||||
|
- (nullable NSString *)toJson; |
||||
|
|
||||
|
/**
|
||||
|
* Applies the settings in this config to a recognizer. |
||||
|
* |
||||
|
* @param recognizer The target recognizer. |
||||
|
*/ |
||||
|
- (void)applyToRecognizer:(nonnull SPXRecognizer *)recognizer |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Applies the settings in this config to a recognizer. |
||||
|
* |
||||
|
* @param recognizer The target recognizer. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)applyToRecognizer:(nonnull SPXRecognizer *)recognizer error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,93 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechRecognitionResult.h" |
||||
|
#import "SPXTimingResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents content assessment result |
||||
|
* Added in version 1.33.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXContentAssessmentResult : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The grammar score. |
||||
|
*/ |
||||
|
@property (readonly) double grammarScore; |
||||
|
|
||||
|
/**
|
||||
|
* The vocabulary score. |
||||
|
*/ |
||||
|
@property (readonly) double vocabularyScore; |
||||
|
|
||||
|
/**
|
||||
|
* The topic score. |
||||
|
*/ |
||||
|
@property (readonly) double topicScore; |
||||
|
|
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Represents pronunciation assessment result |
||||
|
* Added in version 1.14.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXPronunciationAssessmentResult : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The pronunciation accuracy of the given speech, which indicates |
||||
|
* how closely the phonemes match a native speaker's pronunciation. |
||||
|
*/ |
||||
|
@property (readonly) double accuracyScore; |
||||
|
|
||||
|
/**
|
||||
|
* The overall score indicating the pronunciation quality of the given speech. |
||||
|
* This is calculated from AccuracyScore, FluencyScore and CompletenessScore with weight. |
||||
|
*/ |
||||
|
@property (readonly)double pronunciationScore; |
||||
|
|
||||
|
/**
|
||||
|
* The score indicating the completeness of the given speech by calculating the ratio of pronounced words towards entire input. |
||||
|
*/ |
||||
|
@property (readonly)double completenessScore; |
||||
|
|
||||
|
/**
|
||||
|
* The score indicating the fluency of the given speech. |
||||
|
*/ |
||||
|
@property (readonly)double fluencyScore; |
||||
|
|
||||
|
/**
|
||||
|
* The prosody score. |
||||
|
*/ |
||||
|
@property (readonly)double prosodyScore; |
||||
|
|
||||
|
/**
|
||||
|
* The content assessment result. |
||||
|
* Only available when content assessment is enabled. |
||||
|
*/ |
||||
|
@property (nonatomic, retain, nullable) SPXContentAssessmentResult *contentAssessmentResult; |
||||
|
|
||||
|
/**
|
||||
|
* Word level pronunciation assessment results. |
||||
|
* |
||||
|
* Added in version 1.21.0 |
||||
|
*/ |
||||
|
@property (nonatomic, retain, nullable) NSArray<SPXWordLevelTimingResult *> *words; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXPronunciationAssessmentResult object using SPXSpeechRecognitionResult. |
||||
|
* |
||||
|
* @param speechRecognitionResult the speech recognition result |
||||
|
* |
||||
|
* @return an instance of auto detection source language result. |
||||
|
*/ |
||||
|
|
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechRecognitionResult *)speechRecognitionResult; |
||||
|
|
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,69 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents a collection of properties and their values. |
||||
|
*/ |
||||
|
@protocol SPXPropertyCollection |
||||
|
|
||||
|
/**
|
||||
|
* Returns the property value. |
||||
|
* If the name is not available, it returns an empty string. |
||||
|
* |
||||
|
* @param name property name. |
||||
|
* @return value of the property. |
||||
|
*/ |
||||
|
-(nullable NSString *)getPropertyByName:(nonnull NSString *)name; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the property value. |
||||
|
* If the name is not available, it returns the specified default value. |
||||
|
* |
||||
|
* @param name property name. |
||||
|
* @param defaultValue default value which is returned if the property is not available in the collection. |
||||
|
* @return value of the property. |
||||
|
*/ |
||||
|
-(nullable NSString *)getPropertyByName:(nonnull NSString *)name defaultValue:(nonnull NSString *)defaultValue; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the property value. |
||||
|
* If the specified id is not available, it returns an empty string. |
||||
|
* |
||||
|
* @param propertyId property id. |
||||
|
* @return value of the property. |
||||
|
*/ |
||||
|
-(nullable NSString *)getPropertyById:(SPXPropertyId)propertyId; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the property value. |
||||
|
* If the specified id is not available, it returns the specified default value. |
||||
|
* |
||||
|
* @param propertyId property id. |
||||
|
* @param defaultValue default value which is returned if the property is not available in the collection. |
||||
|
* @return value of the property. |
||||
|
*/ |
||||
|
-(nullable NSString *)getPropertyById:(SPXPropertyId)propertyId defaultValue:(nonnull NSString *)defaultValue; |
||||
|
|
||||
|
@optional |
||||
|
/**
|
||||
|
* Sets the property value by name. |
||||
|
* |
||||
|
* @param name property name. |
||||
|
* @param value value of the property. |
||||
|
*/ |
||||
|
-(void)setPropertyTo:(nonnull NSString *)value byName:(nonnull NSString *)name; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the property value by property id. |
||||
|
* |
||||
|
* @param propertyId property id. |
||||
|
* @param value value of the property. |
||||
|
*/ |
||||
|
-(void)setPropertyTo:(nonnull NSString *)value byId:(SPXPropertyId)propertyId; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,21 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSessionEventArgs.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload for SpeechStartDetected and SpeechEndDetected events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXRecognitionEventArgs : SPXSessionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* Represents the message offset in ticks. |
||||
|
* A single tick represents one hundred nanoseconds or one ten-millionth of a second. |
||||
|
*/ |
||||
|
@property (readonly)uint64_t offset; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,134 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents the recognition result base class. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXRecognitionResult : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The result identifier. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *resultId; |
||||
|
|
||||
|
/**
|
||||
|
* The reason the result was created. |
||||
|
*/ |
||||
|
@property (readonly)SPXResultReason reason; |
||||
|
|
||||
|
/**
|
||||
|
* The recognized text in the result. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *text; |
||||
|
|
||||
|
/**
|
||||
|
* Duration of recognized speech in ticks. |
||||
|
* A single tick represents one hundred nanoseconds or one ten-millionth of a second. |
||||
|
*/ |
||||
|
@property (readonly)uint64_t duration; |
||||
|
|
||||
|
/**
|
||||
|
* Offset of recognized speech in milliseconds. |
||||
|
* A single tick represents one hundred nanoseconds or one ten-millionth of a second. |
||||
|
*/ |
||||
|
@property (readonly)uint64_t offset; |
||||
|
|
||||
|
/**
|
||||
|
* Index of the input audio channel where the speech was recognized. |
||||
|
* Numbering starts at zero. |
||||
|
*/ |
||||
|
@property (readonly)uint32_t channel; |
||||
|
|
||||
|
/**
|
||||
|
* The set of properties exposed in the result. |
||||
|
*/ |
||||
|
@property (readonly, nullable)id <SPXPropertyCollection> properties; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Defines detailed information about why a result was canceled. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXCancellationDetails : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The reason the recognition was canceled. |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationReason reason; |
||||
|
|
||||
|
/**
|
||||
|
* The error code in case of an unsuccessful recognition (reason is set to Error). |
||||
|
* |
||||
|
* Added in version 1.1.0. |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationErrorCode errorCode; |
||||
|
|
||||
|
/**
|
||||
|
* The error message in case of an unsuccessful recognition (reason is set to Error). |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *errorDetails; |
||||
|
|
||||
|
/**
|
||||
|
* Creates an instance of SPXCancellationDetails object for the canceled SPXSpeechRecognitionResult. |
||||
|
* |
||||
|
* @param recognitionResult The result that was canceled. |
||||
|
* @return The cancellation details object being created. |
||||
|
*/ |
||||
|
-(nullable instancetype)initFromCanceledRecognitionResult:(nonnull SPXRecognitionResult *)recognitionResult |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Creates an instance of SPXCancellationDetails object for the canceled SPXSpeechRecognitionResult. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param recognitionResult The result that was canceled. |
||||
|
* @param outError error information. |
||||
|
* @return The cancellation details object being created. |
||||
|
*/ |
||||
|
-(nullable instancetype)initFromCanceledRecognitionResult:(nonnull SPXRecognitionResult *)recognitionResult error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Defines detailed information for NoMatch recognition results. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXNoMatchDetails : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The reason why NoMatch is returned. |
||||
|
*/ |
||||
|
@property (readonly)SPXNoMatchReason reason; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of SPXNoMatchDetails object from a NoMatch result. |
||||
|
* |
||||
|
* @param recognitionResult recognition result that has NoMatch returned in Reason. |
||||
|
* @return an SPXNoMatchDetails instance. |
||||
|
*/ |
||||
|
-(nullable instancetype)initFromNoMatchRecognitionResult:(nonnull SPXRecognitionResult *)recognitionResult |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of SPXNoMatchDetails object from a NoMatch result. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param recognitionResult recognition result that has NoMatch returned in Reason. |
||||
|
* @param outError error information. |
||||
|
* @return an SPXNoMatchDetails instance. |
||||
|
*/ |
||||
|
-(nullable instancetype)initFromNoMatchRecognitionResult:(nonnull SPXRecognitionResult *)recognitionResult error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,54 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSessionEventArgs.h" |
||||
|
#import "SPXRecognitionEventArgs.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the base class SPXRecognizer which mainly contains common event handlers. |
||||
|
*/ |
||||
|
|
||||
|
SPX_EXPORT |
||||
|
@interface SPXRecognizer : NSObject |
||||
|
|
||||
|
typedef void (^SPXSessionEventHandler)(SPXRecognizer * _Nonnull, SPXSessionEventArgs * _Nonnull); |
||||
|
typedef void (^SPXRecognitionEventHandler)(SPXRecognizer * _Nonnull, SPXRecognitionEventArgs * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* The collection of properties and their values defined for this SPXRecognizer. |
||||
|
*/ |
||||
|
@property (readonly, nullable)id <SPXPropertyCollection> properties; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the SessionStarted event using the specified handler. |
||||
|
* |
||||
|
* @param eventHandler the handler function for this event. |
||||
|
*/ |
||||
|
- (void)addSessionStartedEventHandler:(nonnull SPXSessionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the SessionStopped event using the specified handler. |
||||
|
* |
||||
|
* @param eventHandler the handler function for this event. |
||||
|
*/ |
||||
|
- (void)addSessionStoppedEventHandler:(nonnull SPXSessionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the SpeechStartDetected event using the specified handler. |
||||
|
* |
||||
|
* @param eventHandler the handler function for this event. |
||||
|
*/ |
||||
|
- (void)addSpeechStartDetectedEventHandler:(nonnull SPXRecognitionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to SpeechEndDetected event using the specified handler. |
||||
|
* |
||||
|
* @param eventHandler the handler function for this event. |
||||
|
*/ |
||||
|
- (void)addSpeechEndDetectedEventHandler:(nonnull SPXRecognitionEventHandler)eventHandler; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,19 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload for SessionStarted/SessionStopped events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSessionEventArgs : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The session identifier. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *sessionId; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,59 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents source language configuration, allowing specifying the source language and customized endpoint |
||||
|
* Added in version 1.12.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSourceLanguageConfiguration : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXSourceLanguageConfiguration object using the language. |
||||
|
* |
||||
|
* @param language value of the language. |
||||
|
* |
||||
|
* @return an instance of source language configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull NSString *)language |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXSourceLanguageConfiguration object using the language. |
||||
|
* |
||||
|
* @param language value of the language. |
||||
|
* @param outError error information. |
||||
|
* |
||||
|
* @return an instance of source language configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull NSString *)language error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXSourceLanguageConfiguration object using the language and corresponding endpoint id |
||||
|
* |
||||
|
* @param language value of the language. |
||||
|
* @param endpointId id of the customized endpoint, will be used to recognize the audio in the source language. |
||||
|
* |
||||
|
* @return an instance of source language configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithLanguage:(nonnull NSString *)language endpointId:(nonnull NSString *)endpointId |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an SPXSourceLanguageConfiguration object using the language and corresponding endpoint id |
||||
|
* |
||||
|
* @param language value of the language. |
||||
|
* @param endpointId id of the customized endpoint, will be used to recognize the audio in the source language. |
||||
|
* @param outError error information. |
||||
|
* |
||||
|
* @return an instance of source language configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithLanguage:(nonnull NSString *)language |
||||
|
endpointId:(nonnull NSString *)endpointId |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,71 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXAudioConfiguration.h" |
||||
|
#import "SPXAudioDataStream.h" |
||||
|
#import "SPXAudioProcessingOptions.h" |
||||
|
#import "SPXAudioStream.h" |
||||
|
#import "SPXAudioStreamFormat.h" |
||||
|
#import "SPXAutoDetectSourceLanguageConfiguration.h" |
||||
|
#import "SPXAutoDetectSourceLanguageResult.h" |
||||
|
#import "SPXConnection.h" |
||||
|
#import "SPXConnectionEventArgs.h" |
||||
|
#import "SPXConversation.h" |
||||
|
#import "SPXConversationEventArgs.h" |
||||
|
#import "SPXConversationTranscriber.h" |
||||
|
#import "SPXConversationTranscriptionEventArgs.h" |
||||
|
#import "SPXConversationTranscriptionResult.h" |
||||
|
#import "SPXConversationTranslationEventArgs.h" |
||||
|
#import "SPXConversationTranslationResult.h" |
||||
|
#import "SPXConversationTranslator.h" |
||||
|
#import "SPXDialogServiceConfiguration.h" |
||||
|
#import "SPXDialogServiceConnector.h" |
||||
|
#import "SPXDialogServiceConnectorActivityReceivedEventArgs.h" |
||||
|
#import "SPXDialogServiceConnectorTurnStatusReceivedEventArgs.h" |
||||
|
#import "SPXEventLogger.h" |
||||
|
#import "SPXEmbeddedSpeechConfiguration.h" |
||||
|
#import "SPXFileLogger.h" |
||||
|
#import "SPXGrammar.h" |
||||
|
#import "SPXGrammarPhrase.h" |
||||
|
#import "SPXIntentRecognitionEventArgs.h" |
||||
|
#import "SPXIntentRecognitionResult.h" |
||||
|
#import "SPXIntentRecognizer.h" |
||||
|
#import "SPXLanguageUnderstandingModel.h" |
||||
|
#import "SPXMeeting.h" |
||||
|
#import "SPXMeetingTranscriber.h" |
||||
|
#import "SPXMeetingTranscriptionEventArgs.h" |
||||
|
#import "SPXMeetingTranscriptionResult.h" |
||||
|
#import "SPXMemoryLogger.h" |
||||
|
#import "SPXKeywordRecognitionEventArgs.h" |
||||
|
#import "SPXKeywordRecognitionResult.h" |
||||
|
#import "SPXKeywordRecognizer.h" |
||||
|
#import "SPXKeywordRecognitionModel.h" |
||||
|
#import "SPXParticipant.h" |
||||
|
#import "SPXPhraseListGrammar.h" |
||||
|
#import "SPXPronunciationAssessmentConfiguration.h" |
||||
|
#import "SPXPronunciationAssessmentResult.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
#import "SPXRecognitionEventArgs.h" |
||||
|
#import "SPXRecognitionResult.h" |
||||
|
#import "SPXRecognizer.h" |
||||
|
#import "SPXSessionEventArgs.h" |
||||
|
#import "SPXSpeechConfiguration.h" |
||||
|
#import "SPXSpeechRecognitionEventArgs.h" |
||||
|
#import "SPXSpeechRecognitionModelInfo.h" |
||||
|
#import "SPXSpeechRecognitionResult.h" |
||||
|
#import "SPXSpeechRecognizer.h" |
||||
|
#import "SPXSpeechSynthesisCancellationDetails.h" |
||||
|
#import "SPXSpeechSynthesisEventArgs.h" |
||||
|
#import "SPXSpeechSynthesizer.h" |
||||
|
#import "SPXSpeechTranslationConfiguration.h" |
||||
|
#import "SPXSpeechTranslationModelInfo.h" |
||||
|
#import "SPXSourceLanguageConfiguration.h" |
||||
|
#import "SPXTranslationRecognitionEventArgs.h" |
||||
|
#import "SPXTranslationRecognitionResult.h" |
||||
|
#import "SPXTranslationRecognizer.h" |
||||
|
#import "SPXTranslationSynthesisEventArgs.h" |
||||
|
#import "SPXTranslationSynthesisResult.h" |
||||
|
#import "SPXUser.h" |
||||
|
#import "SPXTimingResult.h" |
||||
@ -0,0 +1,402 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines configurations for speech or intent recognition. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechConfiguration : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Tag of speech recognition language, using BCP-47 format. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *speechRecognitionLanguage; |
||||
|
|
||||
|
/**
|
||||
|
* Endpoint ID of a customized speech model that is used for speech recognition, or a custom voice model for speech synthesis. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *endpointId; |
||||
|
|
||||
|
/**
|
||||
|
* The output format of the speech recognition result. |
||||
|
* |
||||
|
* Note: This output format is for speech recognition result, use SPXSpeechConfiguration.speechSynthesisOutputFormat |
||||
|
* and SPXSpeechConfiguration.setSpeechSynthesisOutputFormat to get/set the systhesized audio output format. |
||||
|
*/ |
||||
|
@property (nonatomic)SPXOutputFormat outputFormat; |
||||
|
|
||||
|
/**
|
||||
|
* Authorization token. |
||||
|
* |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token |
||||
|
* expires, the caller needs to refresh it by calling this setter with a new valid token. |
||||
|
* As configuration values are copied when creating a new recognizer, the new token value will not apply to recognizers that have already been created. |
||||
|
* For recognizers that have been created before, you need to set authorization token of the corresponding recognizer |
||||
|
* to refresh the token. Otherwise, the recognizers will encounter errors during recognition. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *authorizationToken; |
||||
|
|
||||
|
/**
|
||||
|
* Subscription key. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nullable)NSString *subscriptionKey; |
||||
|
|
||||
|
/**
|
||||
|
* Region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nullable)NSString *region; |
||||
|
|
||||
|
/**
|
||||
|
* Speech synthesis language. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *speechSynthesisLanguage; |
||||
|
|
||||
|
/**
|
||||
|
* Speech synthesis voice. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *speechSynthesisVoiceName; |
||||
|
|
||||
|
/**
|
||||
|
* Speech synthesis optput format. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nullable)NSString* speechSynthesisOutputFormat; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of a speech configuration with the specified subscription key and service region. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param subscriptionKey the subscription key to be used. |
||||
|
* @param region the region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). |
||||
|
* @param outError error information. |
||||
|
* @return a speech configuration instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSubscription:(nonnull NSString *)subscriptionKey region:(nonnull NSString *)region error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of a speech configuration with the specified subscription key and service region. |
||||
|
* |
||||
|
* @param subscriptionKey the subscription key to be used. |
||||
|
* @param region the region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). |
||||
|
* @return a speech configuration instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSubscription:(nonnull NSString *)subscriptionKey region:(nonnull NSString *)region |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of a speech configuration with specified authorization token and service region. |
||||
|
* |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token |
||||
|
* expires, the caller needs to refresh it by calling this setter with a new valid token. |
||||
|
* As configuration values are copied when creating a new recognizer, the new token value will not apply to recognizers that have already been created. |
||||
|
* For recognizers that have been created before, you need to set authorization token of the corresponding recognizer |
||||
|
* to refresh the token. Otherwise, the recognizers will encounter errors during recognition. |
||||
|
* |
||||
|
* @param authToken the authorization token. |
||||
|
* @param region the region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). |
||||
|
* @return a speech configuration instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAuthorizationToken:(nonnull NSString *)authToken region:(nonnull NSString *)region |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of a speech configuration with specified authorization token and service region. |
||||
|
* |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token |
||||
|
* expires, the caller needs to refresh it by calling this setter with a new valid token. |
||||
|
* As configuration values are copied when creating a new recognizer, the new token value will not apply to recognizers that have already been created. |
||||
|
* For recognizers that have been created before, you need to set authorization token of the corresponding recognizer |
||||
|
* to refresh the token. Otherwise, the recognizers will encounter errors during recognition. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param authToken the authorization token. |
||||
|
* @param region the region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). |
||||
|
* @param outError error information. |
||||
|
* @return a speech configuration instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAuthorizationToken:(nonnull NSString *)authToken region:(nonnull NSString *)region error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the speech configuration with specified endpoint and subscription key. |
||||
|
* This method is intended only for users who use a non-standard service endpoint or parameters. |
||||
|
* |
||||
|
* Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. |
||||
|
* Whether a specific query parameter is supported or not, depends on the endpoint and scenario. |
||||
|
* For example, if the recognition language is defined in the URI as query parameter "language=de-DE", and is also set to "en-US" via |
||||
|
* property speechRecognitionLanguage in SPXSpeechConfiguration, the language setting in the URI takes precedence, and the effective language is "de-DE". |
||||
|
* The example only applies when the endpoint and scenario combination supports language as a query parameter. |
||||
|
* Only the parameters that are not specified in the endpoint URI can be set by other APIs. |
||||
|
* |
||||
|
* Note: To use an authorization token, use initWithEndpoint, and then set the authorizationToken property on the created SPXSpeechConfiguration instance. |
||||
|
* |
||||
|
* @param endpointUri The service endpoint to connect to. |
||||
|
* @param subscriptionKey the subscription key. |
||||
|
* @return A speech configuration instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEndpoint:(nonnull NSString *)endpointUri subscription:(nonnull NSString *)subscriptionKey |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the speech configuration with specified endpoint and subscription key. |
||||
|
* This method is intended only for users who use a non-standard service endpoint or parameters. |
||||
|
* |
||||
|
* Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. |
||||
|
* For example, if the recognition language is defined in the URI as query parameter "language=de-DE", and is also set to "en-US" via |
||||
|
* property speechRecognitionLanguage in SPXSpeechConfiguration, the language setting in the URI takes precedence, and the effective language is "de-DE". |
||||
|
* Only the parameters that are not specified in the endpoint URI can be set by other APIs. |
||||
|
* |
||||
|
* Note: To use an authorization token, use initWithEndpoint, and then set the authorizationToken property on the created SPXSpeechConfiguration instance. |
||||
|
* |
||||
|
* Added in version 1.5.0. |
||||
|
* |
||||
|
* @param endpointUri The service endpoint to connect to. |
||||
|
* @param subscriptionKey the subscription key. |
||||
|
* @param outError error information. |
||||
|
* @return A speech configuration instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEndpoint:(nonnull NSString *)endpointUri subscription:(nonnull NSString *)subscriptionKey error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the speech configuration with specified endpoint. |
||||
|
* This method is intended only for users who use a non-standard service endpoint or parameters. |
||||
|
* |
||||
|
* Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. |
||||
|
* For example, if the recognition language is defined in the uri as query parameter "language=de-DE", and is also set to "en-US" via |
||||
|
* property speechRecognitionLanguage in SpeechConfiguration, the language setting in the uri takes precedence, and the effective language is "de-DE". |
||||
|
* Only the parameters that are not specified in the endpoint URL can be set by other APIs. |
||||
|
* |
||||
|
* Note: if the endpoint requires a subscription key for authentication, please use initWithEndpoint:subscription: to pass the subscription key as parameter. |
||||
|
* To use an authorization token, use this method to create a SpeechConfig instance, and then set the authorizationToken property on the created SPXSpeechConfiguration instance. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param endpointUri The service endpoint to connect to. |
||||
|
* @return A speech configuration instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEndpoint:(nonnull NSString *)endpointUri |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the speech configuration with specified endpoint. |
||||
|
* This method is intended only for users who use a non-standard service endpoint or parameters. |
||||
|
* |
||||
|
* Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. |
||||
|
* For example, if the recognition language is defined in the uri as query parameter "language=de-DE", and is also set to "en-US" via |
||||
|
* property speechRecognitionLanguage in SpeechConfiguration, the language setting in the uri takes precedence, and the effective language is "de-DE". |
||||
|
* Only the parameters that are not specified in the endpoint URL can be set by other APIs. |
||||
|
* |
||||
|
* Note: if the endpoint requires a subscription key for authentication, please use initWithEndpoint:subscription: to pass the subscription key as parameter. |
||||
|
* To use an authorization token, use this method to create a SpeechConfig instance, and then set the authorizationToken property on the created SPXSpeechConfiguration instance. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param endpointUri The service endpoint to connect to. |
||||
|
* @param outError error information. |
||||
|
* @return A speech configuration instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEndpoint:(nonnull NSString *)endpointUri error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the speech configuration with specified host and subscription key. |
||||
|
* This method is intended only for users who use a non-default service host. Standard resource path will be assumed. |
||||
|
* For services with a non-standard resource path or no path at all, use initWithEndpoint instead. |
||||
|
* |
||||
|
* Note: Query parameters are not allowed in the host URI and must be set by other APIs. |
||||
|
* |
||||
|
* Note: To use an authorization token, use initWithHost, and then set the authorizationToken property on the created SPXSpeechConfiguration instance. |
||||
|
* |
||||
|
* Added in version 1.8.0. |
||||
|
* |
||||
|
* @param hostUri The service host to connect to. Format is "protocol://host:port" where ":port" is optional. |
||||
|
* @param subscriptionKey The subscription key. |
||||
|
* @return A speech configuration instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithHost:(nonnull NSString *)hostUri subscription:(nonnull NSString *)subscriptionKey |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the speech configuration with specified host and subscription key. |
||||
|
* This method is intended only for users who use a non-default service host. Standard resource path will be assumed. |
||||
|
* For services with a non-standard resource path or no path at all, use initWithEndpoint instead. |
||||
|
* |
||||
|
* Note: Query parameters are not allowed in the host URI and must be set by other APIs. |
||||
|
* |
||||
|
* Note: To use an authorization token, use initWithHost, and then set the authorizationToken property on the created SPXSpeechConfiguration instance. |
||||
|
* |
||||
|
* Added in version 1.8.0. |
||||
|
* |
||||
|
* @param hostUri The service host to connect to. Format is "protocol://host:port" where ":port" is optional. |
||||
|
* @param subscriptionKey The subscription key. |
||||
|
* @param outError Error information. |
||||
|
* @return A speech configuration instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithHost:(nonnull NSString *)hostUri subscription:(nonnull NSString *)subscriptionKey error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the speech configuration with specified host. |
||||
|
* This method is intended only for users who use a non-default service host. Standard resource path will be assumed. |
||||
|
* For services with a non-standard resource path or no path at all, use initWithEndpoint instead. |
||||
|
* |
||||
|
* Note: Query parameters are not allowed in the host URI and must be set by other APIs. |
||||
|
* |
||||
|
* Note: If the host requires a subscription key for authentication, use initWithHost:subscription: to pass the subscription key as parameter. |
||||
|
* To use an authorization token, use this method to create a SpeechConfig instance, and then set the authorizationToken property on the created SPXSpeechConfiguration instance. |
||||
|
* |
||||
|
* Added in version 1.8.0. |
||||
|
* |
||||
|
* @param hostUri The service host to connect to. Format is "protocol://host:port" where ":port" is optional. |
||||
|
* @return A speech configuration instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithHost:(nonnull NSString *)hostUri |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Initializes an instance of the speech configuration with specified host. |
||||
|
* This method is intended only for users who use a non-default service host. Standard resource path will be assumed. |
||||
|
* For services with a non-standard resource path or no path at all, use initWithEndpoint instead. |
||||
|
* |
||||
|
* Note: Query parameters are not allowed in the host URI and must be set by other APIs. |
||||
|
* |
||||
|
* Note: If the host requires a subscription key for authentication, use initWithHost:subscription: to pass the subscription key as parameter. |
||||
|
* To use an authorization token, use this method to create a SpeechConfig instance, and then set the authorizationToken property on the created SPXSpeechConfiguration instance. |
||||
|
* |
||||
|
* Added in version 1.8.0. |
||||
|
* |
||||
|
* @param hostUri The service host to connect to. Format is "protocol://host:port" where ":port" is optional. |
||||
|
* @param outError Error information. |
||||
|
* @return A speech configuration instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithHost:(nonnull NSString *)hostUri error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Sets proxy configuration |
||||
|
* |
||||
|
* Added in version 1.1.0 |
||||
|
* |
||||
|
* Note: Proxy functionality is not available on iOS and macOS. This function will have no effect on these platforms. |
||||
|
* |
||||
|
* @param proxyHostName the host name of the proxy server, without the protocol scheme (http://)
|
||||
|
* @param proxyPort the port number of the proxy server. |
||||
|
* @param proxyUserName the user name of the proxy server. Use empty string if no user name is needed. |
||||
|
* @param proxyPassword the password of the proxy server. Use empty string if no user password is needed. |
||||
|
*/ |
||||
|
-(void)setProxyUsingHost:(nonnull NSString *)proxyHostName Port:(uint32_t)proxyPort UserName:(nullable NSString *)proxyUserName Password:(nullable NSString *)proxyPassword |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Sets proxy configuration |
||||
|
* |
||||
|
* Note: Proxy functionality is not available on iOS and macOS. This function will have no effect on these platforms. |
||||
|
* |
||||
|
* Added in version 1.6.0 |
||||
|
* |
||||
|
* @param proxyHostName the host name of the proxy server, without the protocol scheme (http://)
|
||||
|
* @param proxyPort the port number of the proxy server. |
||||
|
* @param proxyUserName the user name of the proxy server. Use empty string if no user name is needed. |
||||
|
* @param proxyPassword the password of the proxy server. Use empty string if no user password is needed. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
-(BOOL)setProxyUsingHost:(nonnull NSString *)proxyHostName Port:(uint32_t)proxyPort UserName:(nullable NSString *)proxyUserName Password:(nullable NSString *)proxyPassword error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the property value. |
||||
|
* If the name is not available, it returns an empty string. |
||||
|
* |
||||
|
* @param name property name. |
||||
|
* @return value of the property. |
||||
|
*/ |
||||
|
-(nullable NSString *)getPropertyByName:(nonnull NSString *)name; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the property value by name. |
||||
|
* |
||||
|
* @param name property name. |
||||
|
* @param value value of the property. |
||||
|
*/ |
||||
|
-(void)setPropertyTo:(nonnull NSString *)value byName:(nonnull NSString *)name; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the property value. |
||||
|
* If the specified id is not available, it returns an empty string. |
||||
|
* |
||||
|
* @param propertyId property id. |
||||
|
* @return value of the property. |
||||
|
*/ |
||||
|
-(nullable NSString *)getPropertyById:(SPXPropertyId)propertyId; |
||||
|
|
||||
|
/**
|
||||
|
* Sets the property value by property id. |
||||
|
* |
||||
|
* @param propertyId property id. |
||||
|
* @param value value of the property. |
||||
|
*/ |
||||
|
-(void)setPropertyTo:(nonnull NSString *)value byId:(SPXPropertyId)propertyId; |
||||
|
|
||||
|
/**
|
||||
|
* Sets a property value that will be passed to service using the specified channel. |
||||
|
* |
||||
|
* Added in version 1.5.0. |
||||
|
* |
||||
|
* @param name the property name. |
||||
|
* @param value the property value. |
||||
|
* @param channel the channel used to pass the specified property to service. |
||||
|
*/ |
||||
|
-(void)setServicePropertyTo:(nonnull NSString *)value byName:(nonnull NSString*)name usingChannel:(SPXServicePropertyChannel)channel; |
||||
|
|
||||
|
/**
|
||||
|
* Sets profanity option. |
||||
|
* |
||||
|
* Added in version 1.5.0. |
||||
|
* |
||||
|
* @param profanity Profanity option value. |
||||
|
*/ |
||||
|
-(void)setProfanityOptionTo:(SPXSpeechConfigProfanityOption)profanity; |
||||
|
|
||||
|
/**
|
||||
|
* Set the speech synthesis audio output format (e.g. Riff16Khz16BitMonoPcm). |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
* |
||||
|
* @param formatId output format id. |
||||
|
*/ |
||||
|
-(void)setSpeechSynthesisOutputFormat:(SPXSpeechSynthesisOutputFormat)formatId; |
||||
|
|
||||
|
/**
|
||||
|
* Enables audio logging in service. |
||||
|
* Audio and content logs are stored either in Microsoft-owned storage, or in your own storage account linked |
||||
|
* to your Cognitive Services subscription (Bring Your Own Storage (BYOS) enabled Speech resource). |
||||
|
* Added in version 1.5.0. |
||||
|
* |
||||
|
*/ |
||||
|
-(void)enableAudioLogging; |
||||
|
|
||||
|
/**
|
||||
|
* Includes word-level timestamps in response result. |
||||
|
* |
||||
|
* Added in version 1.5.0. |
||||
|
*/ |
||||
|
-(void)requestWordLevelTimestamps; |
||||
|
|
||||
|
/**
|
||||
|
* Enables dictation mode. Only supported in speech continuous recognition. |
||||
|
* |
||||
|
* Added in version 1.5.0. |
||||
|
*/ |
||||
|
-(void)enableDictation; |
||||
|
|
||||
|
@end |
||||
File diff suppressed because it is too large
@ -0,0 +1,47 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognitionEventArgs.h" |
||||
|
#import "SPXSpeechRecognitionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of speech recognizing/recognized event. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechRecognitionEventArgs : SPXRecognitionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* The recognition result. |
||||
|
*/ |
||||
|
@property (readonly, nonnull)SPXSpeechRecognitionResult *result; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of speech recognition canceled events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechRecognitionCanceledEventArgs : SPXSpeechRecognitionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* The reason why the recognition was canceled. |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationReason reason; |
||||
|
|
||||
|
/**
|
||||
|
* The error code in case of an unsuccessful recognition (reason is set to Error). |
||||
|
* |
||||
|
* Added in version 1.1.0. |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationErrorCode errorCode; |
||||
|
|
||||
|
/**
|
||||
|
* The error message in case of an unsuccessful recognition (reason is set to Error). |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *errorDetails; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,48 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
|
||||
|
/**
|
||||
|
* Speech recognition model information. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechRecognitionModelInfo : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* Model name. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nullable) NSString *name; |
||||
|
|
||||
|
/**
|
||||
|
* Locales of the model in BCP-47 format. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nullable) NSArray<NSString *> *locales; |
||||
|
|
||||
|
/**
|
||||
|
* Model path (only valid for offline models). |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nullable) NSString *path; |
||||
|
|
||||
|
/**
|
||||
|
* Model version. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nullable) NSString *version; |
||||
|
|
||||
|
/**
|
||||
|
* Initialize a new instance of SPXSpeechRecognitionModelInfo. |
||||
|
* |
||||
|
* @param name The model name. |
||||
|
* @param locales The locales of the model in BCP-47 format. |
||||
|
* @param path The model path (only valid for offline models). |
||||
|
* @param version The model version. |
||||
|
* @return A new instance of SPXSpeechRecognitionModelInfo. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithName:(nonnull NSString *)name |
||||
|
locales:(nonnull NSArray<NSString *> *)locales |
||||
|
path:(nullable NSString *)path |
||||
|
version:(nonnull NSString *)version; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,17 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognitionResult.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the result of speech recognition. |
||||
|
* Currently no additional properties and methods, besides those from SPXRecognitionResult. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechRecognitionResult : SPXRecognitionResult |
||||
|
|
||||
|
@end |
||||
|
|
||||
@ -0,0 +1,556 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXAudioConfiguration.h" |
||||
|
#import "SPXAutoDetectSourceLanguageConfiguration.h" |
||||
|
#import "SPXSourceLanguageConfiguration.h" |
||||
|
#import "SPXSpeechConfiguration.h" |
||||
|
#import "SPXSpeechRecognizer.h" |
||||
|
#import "SPXSpeechRecognitionResult.h" |
||||
|
#import "SPXSpeechRecognitionEventArgs.h" |
||||
|
#import "SPXEmbeddedSpeechConfiguration.h" |
||||
|
|
||||
|
/**
|
||||
|
* Performs speech recognition on the specified audio input, and gets transcribed text as result. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechRecognizer : SPXRecognizer |
||||
|
|
||||
|
typedef void (^SPXSpeechRecognitionEventHandler)(SPXSpeechRecognizer * _Nonnull, SPXSpeechRecognitionEventArgs * _Nonnull); |
||||
|
typedef void (^SPXSpeechRecognitionCanceledEventHandler)(SPXSpeechRecognizer * _Nonnull, SPXSpeechRecognitionCanceledEventArgs * _Nonnull); |
||||
|
typedef void (^SPXSpeechRecognitionAsyncCompletionHandler)(void); |
||||
|
|
||||
|
/**
|
||||
|
* Authorization token used to communicate with the speech recognition service. |
||||
|
* |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, |
||||
|
* the caller needs to refresh it by calling this setter with a new valid token. |
||||
|
* Otherwise, the recognizer will encounter errors during recognition. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *authorizationToken; |
||||
|
|
||||
|
/**
|
||||
|
* Endpoint ID of a customized speech model that is used for speech recognition. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nullable)NSString *endpointId; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer. |
||||
|
* |
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer. |
||||
|
* |
||||
|
* @param speechConfiguration embedded speech recognition configuration. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEmbeddedSpeechConfiguration:(nonnull SPXEmbeddedSpeechConfiguration *)speechConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer. |
||||
|
* |
||||
|
* @param speechConfiguration embedded speech recognition configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEmbeddedSpeechConfiguration:(nonnull SPXEmbeddedSpeechConfiguration *)speechConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified audio config. |
||||
|
* |
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified audio config. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified audio config. |
||||
|
* |
||||
|
* @param speechConfiguration embedded speech recognition configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEmbeddedSpeechConfiguration:(nonnull SPXEmbeddedSpeechConfiguration *)speechConfiguration audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified audio config. |
||||
|
* |
||||
|
* @param speechConfiguration embedded speech recognition configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEmbeddedSpeechConfiguration:(nonnull SPXEmbeddedSpeechConfiguration *)speechConfiguration audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified source language. |
||||
|
* |
||||
|
* Added in version 1.12.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param language source language. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration language:(nonnull NSString *)language |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified source language. |
||||
|
* |
||||
|
* Added in version 1.12.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param language source language. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
language:(nonnull NSString *)language |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified source language and audio configuration. |
||||
|
* |
||||
|
* Added in version 1.12.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param language source language. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
language:(nonnull NSString *)language |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified source language and audio configuration. |
||||
|
* |
||||
|
* Added in version 1.12.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param language source language. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
language:(nonnull NSString *)language |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified source language configuration. |
||||
|
* |
||||
|
* Added in version 1.12.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param sourceLanguageConfiguration the source language configuration. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
sourceLanguageConfiguration:(nonnull SPXSourceLanguageConfiguration *)sourceLanguageConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified source language configuration. |
||||
|
* |
||||
|
* Added in version 1.12.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param sourceLanguageConfiguration the source language configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
sourceLanguageConfiguration:(nonnull SPXSourceLanguageConfiguration *)sourceLanguageConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified source language configuration and audio configuration. |
||||
|
* |
||||
|
* Added in version 1.12.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param sourceLanguageConfiguration the source language configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
sourceLanguageConfiguration:(nonnull SPXSourceLanguageConfiguration *)sourceLanguageConfiguration |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified source language configuration and audio configuration. |
||||
|
* |
||||
|
* Added in version 1.12.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param sourceLanguageConfiguration the source language configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
sourceLanguageConfiguration:(nonnull SPXSourceLanguageConfiguration *)sourceLanguageConfiguration |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified configuration for auto language detection. |
||||
|
* |
||||
|
* Added in version 1.12.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified configuration for auto language detection. |
||||
|
* |
||||
|
* Added in version 1.12.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified configuration for auto language detection. |
||||
|
* |
||||
|
* @param speechConfiguration embedded speech recognition configuration. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEmbeddedSpeechConfiguration:(nonnull SPXEmbeddedSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified configuration for auto language detection. |
||||
|
* |
||||
|
* @param speechConfiguration embedded speech recognition configuration. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEmbeddedSpeechConfiguration:(nonnull SPXEmbeddedSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified configuration for auto language detection and audio configuration. |
||||
|
* |
||||
|
* Added in version 1.12.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified configuration for auto language detection and audio configuration. |
||||
|
* |
||||
|
* Added in version 1.12.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified configuration for auto language detection and audio configuration. |
||||
|
* |
||||
|
* @param speechConfiguration embedded speech recognition configuration. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEmbeddedSpeechConfiguration:(nonnull SPXEmbeddedSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech recognizer using the specified configuration for auto language detection and audio configuration. |
||||
|
* |
||||
|
* @param speechConfiguration embedded speech recognition configuration. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech recognizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEmbeddedSpeechConfiguration:(nonnull SPXEmbeddedSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
audioConfiguration:(nonnull SPXAudioConfiguration *)audioConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Starts speech recognition, and returns after a single utterance is recognized. The end of a |
||||
|
* single utterance is determined by listening for silence at the end or until a maximum of about 30 |
||||
|
* seconds of audio is processed. The task returns the recognition text as result. |
||||
|
* |
||||
|
* Note: Since recognizeOnceAsync() returns only a single utterance, it is suitable only for single |
||||
|
* shot recognition like command or query. |
||||
|
* For long-running multi-utterance recognition, use startContinuousRecognition() instead. |
||||
|
* |
||||
|
* @return the result of speech recognition. |
||||
|
*/ |
||||
|
- (nonnull SPXSpeechRecognitionResult *)recognizeOnce |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling.") NS_RETURNS_RETAINED; |
||||
|
|
||||
|
/**
|
||||
|
* Starts speech recognition, and returns after a single utterance is recognized. The end of a |
||||
|
* single utterance is determined by listening for silence at the end or until a maximum of about 30 |
||||
|
* seconds of audio is processed. The task returns the recognition text as result. |
||||
|
* |
||||
|
* Note: Since recognizeOnceAsync() returns only a single utterance, it is suitable only for single |
||||
|
* shot recognition like command or query. |
||||
|
* For long-running multi-utterance recognition, use startContinuousRecognition() instead. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return the result of speech recognition. |
||||
|
*/ |
||||
|
- (nullable SPXSpeechRecognitionResult *)recognizeOnce:(NSError * _Nullable * _Nullable)outError NS_RETURNS_RETAINED; |
||||
|
|
||||
|
/**
|
||||
|
* Starts speech recognition, and returns after a single utterance is recognized. The end of a |
||||
|
* single utterance is determined by listening for silence at the end or until a maximum of about 30 |
||||
|
* seconds of audio is processed. The task returns the recognition text as result. |
||||
|
* |
||||
|
* Note: Since recognizeOnceAsync() returns only a single utterance, it is suitable only for single |
||||
|
* shot recognition like command or query. |
||||
|
* For long-running multi-utterance recognition, use startContinuousRecognition() instead. |
||||
|
* |
||||
|
* @param resultReceivedHandler the block function to be called when the first utterance has been recognized. |
||||
|
*/ |
||||
|
- (void)recognizeOnceAsync:(nonnull void (^)(SPXSpeechRecognitionResult * _Nonnull))resultReceivedHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Starts speech recognition, and returns after a single utterance is recognized. The end of a |
||||
|
* single utterance is determined by listening for silence at the end or until a maximum of about 30 |
||||
|
* seconds of audio is processed. The task returns the recognition text as result. |
||||
|
* |
||||
|
* Note: Since recognizeOnceAsync() returns only a single utterance, it is suitable only for single |
||||
|
* shot recognition like command or query. |
||||
|
* For long-running multi-utterance recognition, use startContinuousRecognition() instead. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param resultReceivedHandler the block function to be called when the first utterance has been recognized. |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)recognizeOnceAsync:(nonnull void (^)(SPXSpeechRecognitionResult * _Nonnull))resultReceivedHandler error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Starts speech recognition on a continuous audio stream, until stopContinuousRecognition() is called. |
||||
|
* User must subscribe to events to receive recognition results. |
||||
|
*/ |
||||
|
- (void)startContinuousRecognition |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Starts speech recognition on a continuous audio stream, until stopContinuousRecognition() is called. |
||||
|
* User must subscribe to events to receive recognition results. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)startContinuousRecognition:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops continuous speech recognition. |
||||
|
*/ |
||||
|
- (void)stopContinuousRecognition |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops continuous speech recognition. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)stopContinuousRecognition:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Begins a speech-to-text interaction with this recognizer using a keyword. |
||||
|
* This interaction will use the provided keyword model to listen for a keyword indefinitely, |
||||
|
* during which audio is not sent to the speech service and all processing is performed locally. |
||||
|
* When a keyword is recognized, SpeechRecognizer will automatically connect to the speech service |
||||
|
* and begin sending audio data from just before the keyword. |
||||
|
* When received, speech-to-text results may be processed by the provided result handler |
||||
|
* or retrieved via a subscription to the recognized event. |
||||
|
* |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the requested keyword recognition successfully started. If NO, outError may |
||||
|
* contain additional information. |
||||
|
*/ |
||||
|
- (BOOL)startKeywordRecognition |
||||
|
:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Begins a speech-to-text interaction with this recognizer using a keyword. |
||||
|
* This interaction will use the provided keyword model to listen for a keyword indefinitely, |
||||
|
* during which audio is not sent to the speech service and all processing is performed locally. |
||||
|
* When a keyword is recognized, SpeechRecognizer will automatically connect to the speech service |
||||
|
* and begin sending audio data from just before the keyword. |
||||
|
* When received, speech-to-text results may be processed by the provided result handler |
||||
|
* or retrieved via a subscription to the recognized event. |
||||
|
* |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
*/ |
||||
|
- (void)startKeywordRecognition:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Asynchronously begins a speech-to-text interaction with this recognizer |
||||
|
* and immediately returns execution to the calling thread. |
||||
|
* This interaction will use the provided keyword model to listen for a keyword indefinitely, |
||||
|
* during which audio is not sent to the speech service and all processing is performed locally. |
||||
|
* When a keyword is recognized, SpeechRecognizer will automatically connect to the speech service |
||||
|
* and begin sending audio data from just before the keyword. |
||||
|
* When received, speech-to-text results may be processed by the provided result handler |
||||
|
* or retrieved via a subscription to the recognized event. |
||||
|
* |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
* @param completionHandler the handler function called when keyword recognition has started. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the request to start keyword recognition was received successfully. If NO, |
||||
|
* additional information may available in outError. |
||||
|
*/ |
||||
|
- (BOOL)startKeywordRecognitionAsync |
||||
|
:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
completionHandler:(nonnull SPXSpeechRecognitionAsyncCompletionHandler)completionHandler |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Asynchronously begins a speech-to-text interaction with this recognizer |
||||
|
* and immediately returns execution to the calling thread. |
||||
|
* This interaction will use the provided keyword model to listen for a keyword indefinitely, |
||||
|
* during which audio is not sent to the speech service and all processing is performed locally. |
||||
|
* When a keyword is recognized, SpeechRecognizer will automatically connect to the speech service |
||||
|
* and begin sending audio data from just before the keyword. |
||||
|
* When received, speech-to-text results may be processed by the provided result handler |
||||
|
* or retrieved via a subscription to the recognized event. |
||||
|
* |
||||
|
* @param keywordModel the keyword recognition model. |
||||
|
* @param completionHandler the handler function called when keyword recognition has started. |
||||
|
*/ |
||||
|
- (void)startKeywordRecognitionAsync |
||||
|
:(nonnull SPXKeywordRecognitionModel *)keywordModel |
||||
|
completionHandler:(nonnull SPXSpeechRecognitionAsyncCompletionHandler)completionHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops any active keyword recognition. |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether keyword recognition was stopped successfully. If NO, additional information may |
||||
|
* be available in outError. |
||||
|
*/ |
||||
|
- (BOOL)stopKeywordRecognition:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops any active keyword recognition. |
||||
|
*/ |
||||
|
- (void)stopKeywordRecognition |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops any active keyword recognition. |
||||
|
* |
||||
|
* @param completionHandler the handler function called when keyword recognition has stopped. |
||||
|
* @param outError error information. |
||||
|
* @return a value indicating whether the request to stop was received successfully. If NO, additional error |
||||
|
* information may be available in outError. |
||||
|
*/ |
||||
|
- (BOOL)stopKeywordRecognitionAsync |
||||
|
:(nonnull SPXSpeechRecognitionAsyncCompletionHandler)completionHandler |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Stops any active keyword recognition. |
||||
|
* |
||||
|
* @param completionHandler the handler function called when keyword recognition has stopped. |
||||
|
*/ |
||||
|
- (void)stopKeywordRecognitionAsync:(nonnull SPXSpeechRecognitionAsyncCompletionHandler)completionHandler |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Recognized event which indicates that a final result has been recognized. |
||||
|
*/ |
||||
|
- (void)addRecognizedEventHandler:(nonnull SPXSpeechRecognitionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Recognizing event which indicates that an intermediate result has been recognized. |
||||
|
*/ |
||||
|
- (void)addRecognizingEventHandler:(nonnull SPXSpeechRecognitionEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Canceled event which indicates that an error occurred during recognition. |
||||
|
*/ |
||||
|
- (void)addCanceledEventHandler:(nonnull SPXSpeechRecognitionCanceledEventHandler)eventHandler; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,71 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
#import "SPXSpeechSynthesisResult.h" |
||||
|
#import "SPXAudioDataStream.h" |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Defines detailed information about why a speech synthesis result was canceled. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechSynthesisCancellationDetails : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The reason the synthesis was canceled. |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationReason reason; |
||||
|
|
||||
|
/**
|
||||
|
* The error message in case of an unsuccessful synthesis (reason is set to Error). If reason is not an error, errorCode returns NoErro. |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationErrorCode errorCode; |
||||
|
|
||||
|
/**
|
||||
|
* The error message in case of an unsuccessful synthesis (reason is set to Error). |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *errorDetails; |
||||
|
|
||||
|
/**
|
||||
|
* Creates an instance of SPXSpeechSynthesisCancellationDetails object for the canceled SPXSpeechSynthesisResult. |
||||
|
* |
||||
|
* @param synthesisResult the synthesis result that was canceled. |
||||
|
* @return the speech synthesis cancellation details object being created. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromCanceledSynthesisResult:(nonnull SPXSpeechSynthesisResult *)synthesisResult |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Creates an instance of SPXSpeechSynthesisCancellationDetails object for the canceled SPXSpeechSynthesisResult. |
||||
|
* |
||||
|
* @param synthesisResult the synthesis result that was canceled. |
||||
|
* @param outError error information. |
||||
|
* @return the speech synthesis cancellation details object being created. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromCanceledSynthesisResult:(nonnull SPXSpeechSynthesisResult *)synthesisResult error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Creates an instance of SPXSpeechSynthesisCancellationDetails object for the canceled SPXAudioDataStream. |
||||
|
* |
||||
|
* @param stream the audio data stream that was canceled. |
||||
|
* @return the speech synthesis cancellation details object being created. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromCanceledAudioDataStream:(nonnull SPXAudioDataStream *)stream |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Creates an instance of SPXSpeechSynthesisCancellationDetails object for the canceled SPXAudioDataStream. |
||||
|
* |
||||
|
* @param stream the audio data stream that was canceled. |
||||
|
* @param outError error information. |
||||
|
* @return the speech synthesis cancellation details object being created. |
||||
|
*/ |
||||
|
- (nullable instancetype)initFromCanceledAudioDataStream:(nonnull SPXAudioDataStream *)stream error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,134 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of speech synthesis event. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechSynthesisEventArgs : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The synthesis result. |
||||
|
*/ |
||||
|
@property (readonly, nonnull)SPXSpeechSynthesisResult *result; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of speech synthesis word boundary event. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechSynthesisWordBoundaryEventArgs : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The result identifier. |
||||
|
* |
||||
|
* Added in version 1.25.0 |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *resultId; |
||||
|
|
||||
|
/**
|
||||
|
* Word boundary audio offset, in ticks (100 nanoseconds). |
||||
|
*/ |
||||
|
@property (readonly)NSUInteger audioOffset; |
||||
|
|
||||
|
/**
|
||||
|
* Time duration of the audio. |
||||
|
* |
||||
|
* Added in version 1.21.0. |
||||
|
*/ |
||||
|
@property (readonly)NSTimeInterval duration; |
||||
|
|
||||
|
/**
|
||||
|
* Word boundary text offset. |
||||
|
*/ |
||||
|
@property (readonly)NSUInteger textOffset; |
||||
|
|
||||
|
/**
|
||||
|
* Word boundary word length. |
||||
|
*/ |
||||
|
@property (readonly)NSUInteger wordLength; |
||||
|
|
||||
|
/**
|
||||
|
* The text. |
||||
|
* |
||||
|
* Added in version 1.21.0 |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *text; |
||||
|
|
||||
|
/**
|
||||
|
* Word boundary type. |
||||
|
* |
||||
|
* Added in version 1.21.0. |
||||
|
*/ |
||||
|
@property (readonly) SPXSpeechSynthesisBoundaryType boundaryType; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of speech synthesis viseme event. |
||||
|
* |
||||
|
* Added in version 1.16.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechSynthesisVisemeEventArgs : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The result identifier. |
||||
|
* |
||||
|
* Added in version 1.25.0 |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *resultId; |
||||
|
|
||||
|
/**
|
||||
|
* Viseme audio offset, in ticks (100 nanoseconds). |
||||
|
*/ |
||||
|
@property (readonly)uint64_t audioOffset; |
||||
|
|
||||
|
/**
|
||||
|
* Viseme ID. |
||||
|
*/ |
||||
|
@property (readonly)NSUInteger visemeId; |
||||
|
|
||||
|
/**
|
||||
|
* The animation of current viseme evenet, could be in svg or other format. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *animation; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of speech synthesis bookmark event. |
||||
|
* |
||||
|
* Added in version 1.16.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechSynthesisBookmarkEventArgs : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The result identifier. |
||||
|
* |
||||
|
* Added in version 1.25.0 |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *resultId; |
||||
|
|
||||
|
/**
|
||||
|
* Audio offset of current bookmark, in ticks (100 nanoseconds). |
||||
|
*/ |
||||
|
@property (readonly)uint64_t audioOffset; |
||||
|
|
||||
|
/**
|
||||
|
* The bookmark text. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *text; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,44 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines the speech synthesis result. |
||||
|
* |
||||
|
* Added in version 1.7.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechSynthesisResult : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The result identifier. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *resultId; |
||||
|
|
||||
|
/**
|
||||
|
* The synthesized audio data. |
||||
|
*/ |
||||
|
@property (readonly, nullable)NSData *audioData; |
||||
|
|
||||
|
/**
|
||||
|
* The reason the result was created. |
||||
|
*/ |
||||
|
@property (readonly)SPXResultReason reason; |
||||
|
|
||||
|
/**
|
||||
|
* The set of properties exposed in the result. |
||||
|
*/ |
||||
|
@property (readonly, nullable)id <SPXPropertyCollection> properties; |
||||
|
|
||||
|
/**
|
||||
|
* The time duration of the synthesized audio. |
||||
|
* Added in version 1.21.0. |
||||
|
*/ |
||||
|
@property (readonly)NSTimeInterval audioDuration; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,352 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXAudioConfiguration.h" |
||||
|
#import "SPXSpeechConfiguration.h" |
||||
|
#import "SPXSpeechSynthesisResult.h" |
||||
|
#import "SPXSpeechSynthesisEventArgs.h" |
||||
|
#import "SPXSynthesisVoicesResult.h" |
||||
|
#import "SPXEmbeddedSpeechConfiguration.h" |
||||
|
|
||||
|
/**
|
||||
|
* Performs speech synthesis from a text to a specified audio output. |
||||
|
* |
||||
|
* Updated in version 1.16.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechSynthesizer : NSObject |
||||
|
|
||||
|
typedef void (^SPXSpeechSynthesisEventHandler)(SPXSpeechSynthesizer * _Nonnull, SPXSpeechSynthesisEventArgs * _Nonnull); |
||||
|
typedef void (^SPXSpeechSynthesisWordBoundaryEventHandler)(SPXSpeechSynthesizer * _Nonnull, SPXSpeechSynthesisWordBoundaryEventArgs * _Nonnull); |
||||
|
typedef void (^SPXSpeechSynthesisVisemeEventHandler)(SPXSpeechSynthesizer * _Nonnull, SPXSpeechSynthesisVisemeEventArgs * _Nonnull); |
||||
|
typedef void (^SPXSpeechSynthesisBookmarkEventHandler)(SPXSpeechSynthesizer * _Nonnull, SPXSpeechSynthesisBookmarkEventArgs * _Nonnull); |
||||
|
|
||||
|
/**
|
||||
|
* The collection of properties and their values defined for this SPXSpeechSynthesizer. |
||||
|
*/ |
||||
|
@property (readonly, nullable)id <SPXPropertyCollection> properties; |
||||
|
|
||||
|
/**
|
||||
|
* Authorization token used to communicate with the speech synthesis service. |
||||
|
* |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, |
||||
|
* the caller needs to refresh it by calling this setter with a new valid token. |
||||
|
* Otherwise, the synthesizer will encounter errors during speech synthesis. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *authorizationToken; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech synthesizer using a speech config. |
||||
|
* This synthesizer will output the audio to default speaker, which will throw an exception if the speaker is not available. |
||||
|
* Please use initWithSpeechConfiguration(speechConfiguration, nil) if you just need the SPXSynthesisResult or SPXAudioDataStream. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration. |
||||
|
* @return an instance of speech synthesizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech synthesizer using a speech config. |
||||
|
* This synthesizer will output the audio to default speaker, which will throw an exception if the speaker is not available. |
||||
|
* Please use initWithSpeechConfiguration(speechConfiguration, nil) if you just need the SPXSynthesisResult or SPXAudioDataStream. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech synthesizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)init:(nonnull SPXSpeechConfiguration *)speechConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech synthesizer using a speech config and audio config. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return an instance of speech synthesizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration audioConfiguration:(nullable SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech synthesizer using a speech config and audio config. |
||||
|
* |
||||
|
* @param speechConfiguration speech configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech synthesizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration audioConfiguration:(nullable SPXAudioConfiguration *)audioConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech synthesizer using a embedded speech config. |
||||
|
* This synthesizer will output the audio to default speaker, which will throw an exception if the speaker is not available. |
||||
|
* Please use initWithEmbeddedSpeechConfiguration(speechConfiguration, nil) if you just need the SPXSynthesisResult or SPXAudioDataStream. |
||||
|
* |
||||
|
* @param speechConfiguration embedded speech configuration. |
||||
|
* @return an instance of speech synthesizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEmbeddedSpeechConfiguration:(nonnull SPXEmbeddedSpeechConfiguration *)speechConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech synthesizer using a embedded speech config. |
||||
|
* This synthesizer will output the audio to default speaker, which will throw an exception if the speaker is not available. |
||||
|
* Please use initWithEmbeddedSpeechConfiguration(speechConfiguration, nil) if you just need the SPXSynthesisResult or SPXAudioDataStream. |
||||
|
* |
||||
|
* @param speechConfiguration embedded speech configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech synthesizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEmbeddedSpeechConfiguration:(nonnull SPXEmbeddedSpeechConfiguration *)speechConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech synthesizer using a embedded speech config and audio config. |
||||
|
* |
||||
|
* @param speechConfiguration embedded speech configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return an instance of speech synthesizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEmbeddedSpeechConfiguration:(nonnull SPXEmbeddedSpeechConfiguration *)speechConfiguration audioConfiguration:(nullable SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech synthesizer using a embedded speech config and audio config. |
||||
|
* |
||||
|
* @param speechConfiguration embedded speech configuration. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech synthesizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEmbeddedSpeechConfiguration:(nonnull SPXEmbeddedSpeechConfiguration *)speechConfiguration audioConfiguration:(nullable SPXAudioConfiguration *)audioConfiguration error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech synthesizer using the specified configuration for auto language detection. |
||||
|
* |
||||
|
* Added in version 1.13.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @return an instance of speech synthesizer |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech synthesizer using the specified configuration for auto language detection. |
||||
|
* |
||||
|
* Added in version 1.13.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech synthesizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech synthesizer using the specified configuration for auto language detection and audio configuration. |
||||
|
* |
||||
|
* Added in version 1.13.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @return an instance of speech synthesizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
audioConfiguration:(nullable SPXAudioConfiguration *)audioConfiguration |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of speech synthesizer using the specified configuration for auto language detection and audio configuration. |
||||
|
* |
||||
|
* Added in version 1.13.0. |
||||
|
|
||||
|
* @param speechConfiguration speech recognition configuration. |
||||
|
* @param autoDetectSourceLanguageConfiguration the configuration for auto language detection. |
||||
|
* @param audioConfiguration audio configuration. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech synthesizer. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSpeechConfiguration:(nonnull SPXSpeechConfiguration *)speechConfiguration |
||||
|
autoDetectSourceLanguageConfiguration:(nonnull SPXAutoDetectSourceLanguageConfiguration *)autoDetectSourceLanguageConfiguration |
||||
|
audioConfiguration:(nullable SPXAudioConfiguration *)audioConfiguration |
||||
|
error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Execute the speech synthesis on plain text. |
||||
|
* |
||||
|
* @param text the plain text for synthesis. |
||||
|
* @return the result of speech synthesis. |
||||
|
*/ |
||||
|
- (nonnull SPXSpeechSynthesisResult *)speakText:(nonnull NSString*)text NS_RETURNS_RETAINED |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Execute the speech synthesis on plain text. |
||||
|
* |
||||
|
* @param text the plain text for synthesis. |
||||
|
* @param outError error information. |
||||
|
* @return the result of speech synthesis. |
||||
|
*/ |
||||
|
- (nullable SPXSpeechSynthesisResult *)speakText:(nonnull NSString*)text error:(NSError * _Nullable * _Nullable)outError NS_RETURNS_RETAINED; |
||||
|
|
||||
|
/**
|
||||
|
* Execute the speech synthesis on SSML. |
||||
|
* |
||||
|
* @param ssml the SSML for synthesis. |
||||
|
* @return the result of speech synthesis. |
||||
|
*/ |
||||
|
- (nonnull SPXSpeechSynthesisResult *)speakSsml:(nonnull NSString*)ssml NS_RETURNS_RETAINED |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Execute the speech synthesis on SSML. |
||||
|
* |
||||
|
* @param ssml the SSML for synthesis. |
||||
|
* @param outError error information. |
||||
|
* @return the result of speech synthesis. |
||||
|
*/ |
||||
|
- (nullable SPXSpeechSynthesisResult *)speakSsml:(nonnull NSString*)ssml error:(NSError * _Nullable * _Nullable)outError NS_RETURNS_RETAINED; |
||||
|
|
||||
|
/**
|
||||
|
* Start the speech synthesis on plain text. |
||||
|
* |
||||
|
* @param text the plain the for synthesis. |
||||
|
* @return the result of speech synthesis. |
||||
|
*/ |
||||
|
- (nonnull SPXSpeechSynthesisResult *)startSpeakingText:(nonnull NSString*)text NS_RETURNS_RETAINED |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Start the speech synthesis on plain text. |
||||
|
* |
||||
|
* @param text the plain text for synthesis. |
||||
|
* @param outError error information. |
||||
|
* @return the result of speech synthesis. |
||||
|
*/ |
||||
|
- (nullable SPXSpeechSynthesisResult *)startSpeakingText:(nonnull NSString*)text error:(NSError * _Nullable * _Nullable)outError NS_RETURNS_RETAINED; |
||||
|
|
||||
|
/**
|
||||
|
* Start the speech synthesis on SSML. |
||||
|
* |
||||
|
* @param ssml the SSML for synthesis. |
||||
|
* @return the result of speech synthesis. |
||||
|
*/ |
||||
|
- (nonnull SPXSpeechSynthesisResult *)startSpeakingSsml:(nonnull NSString*)ssml NS_RETURNS_RETAINED |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Start the speech synthesis on SSML. |
||||
|
* |
||||
|
* @param ssml the SSML for synthesis. |
||||
|
* @param outError error information. |
||||
|
* @return the result of speech synthesis. |
||||
|
*/ |
||||
|
- (nullable SPXSpeechSynthesisResult *)startSpeakingSsml:(nonnull NSString*)ssml error:(NSError * _Nullable * _Nullable)outError NS_RETURNS_RETAINED; |
||||
|
|
||||
|
/**
|
||||
|
* Stops synthesis. |
||||
|
* This method will stop the playback and clear the unread data in SPXPullAudioOutputStream |
||||
|
* |
||||
|
* Added in version 1.14.0 |
||||
|
*/ |
||||
|
- (void)stopSpeaking |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Stops synthesis. |
||||
|
* This method will stop the playback and clear the unread data in SPXPullAudioOutputStream |
||||
|
* |
||||
|
* Added in version 1.14.0 |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
*/ |
||||
|
- (BOOL)stopSpeaking:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Get the available voices. |
||||
|
* |
||||
|
* Added in version 1.16.0 |
||||
|
* |
||||
|
* @param locale Specify the locale of voices, in BCP-47 format; or leave it empty to get all available voices. |
||||
|
* @return the result of voices retrieved. |
||||
|
*/ |
||||
|
- (nonnull SPXSynthesisVoicesResult *)getVoicesWithLocale:(nonnull NSString*)locale NS_RETURNS_RETAINED |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Get the available voices. |
||||
|
* |
||||
|
* Added in version 1.16.0 |
||||
|
* |
||||
|
* @param locale Specify the locale of voices, in BCP-47 format; or leave it empty to get all available voices. |
||||
|
* @param outError error information. |
||||
|
* @return the result of voices retrieved. |
||||
|
*/ |
||||
|
- (nullable SPXSynthesisVoicesResult *)getVoicesWithLocale:(nonnull NSString*)locale error:(NSError * _Nullable * _Nullable)outError NS_RETURNS_RETAINED; |
||||
|
|
||||
|
/**
|
||||
|
* Get the available voices in all locales. |
||||
|
* |
||||
|
* Added in version 1.16.0 |
||||
|
* |
||||
|
* @return the result of voices retrieved. |
||||
|
*/ |
||||
|
- (nonnull SPXSynthesisVoicesResult *)getVoices NS_RETURNS_RETAINED |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Get the available voices in all locales. |
||||
|
* |
||||
|
* Added in version 1.16.0 |
||||
|
* |
||||
|
* @param outError error information. |
||||
|
* @return the result of voices retrieved. |
||||
|
*/ |
||||
|
- (nullable SPXSynthesisVoicesResult *)getVoices:(NSError * _Nullable * _Nullable)outError NS_RETURNS_RETAINED; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the SynthesisStarted event which indicates that the synthesis just started. |
||||
|
*/ |
||||
|
- (void)addSynthesisStartedEventHandler:(nonnull SPXSpeechSynthesisEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the Synthesizing event which indicates that the synthesis is on going. |
||||
|
*/ |
||||
|
- (void)addSynthesizingEventHandler:(nonnull SPXSpeechSynthesisEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the SynthesisCompleted event which indicates that the synthesis completed. |
||||
|
*/ |
||||
|
- (void)addSynthesisCompletedEventHandler:(nonnull SPXSpeechSynthesisEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the SynthesisCanceled event which indicates that the synthesis is canceled. |
||||
|
*/ |
||||
|
- (void)addSynthesisCanceledEventHandler:(nonnull SPXSpeechSynthesisEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the SynthesisWordBoundary event which indicates that a word boundary is received. |
||||
|
*/ |
||||
|
- (void)addSynthesisWordBoundaryEventHandler:(nonnull SPXSpeechSynthesisWordBoundaryEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the VisemeReceived event which indicates that a viseme is received. |
||||
|
*/ |
||||
|
- (void)addVisemeReceivedEventHandler:(nonnull SPXSpeechSynthesisVisemeEventHandler)eventHandler; |
||||
|
|
||||
|
/**
|
||||
|
* Subscribes to the BookmarkReached event which indicates that a bookmark is reached. |
||||
|
*/ |
||||
|
- (void)addBookmarkReachedEventHandler:(nonnull SPXSpeechSynthesisBookmarkEventHandler)eventHandler; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,256 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechConfiguration.h" |
||||
|
|
||||
|
/**
|
||||
|
* Defines configurations for translation with speech input. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechTranslationConfiguration : SPXSpeechConfiguration |
||||
|
|
||||
|
/**
|
||||
|
* All target languages that have been configured for translation. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, readonly, nonnull)NSArray *targetLanguages; |
||||
|
|
||||
|
/**
|
||||
|
* Voice name of the synthesis output of translated language. |
||||
|
*/ |
||||
|
@property (nonatomic, copy, nullable)NSString *voiceName; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes speech translation configuration with the specified subscription key and service region. |
||||
|
* |
||||
|
* @param subscriptionKey the key of subscription to be used. |
||||
|
* @param region the region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). |
||||
|
* @return an instance of speech translation configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSubscription:(nonnull NSString *)subscriptionKey region:(nonnull NSString *)region |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes speech translation configuration with the specified subscription key and service region. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param subscriptionKey the key of subscription to be used. |
||||
|
* @param region the region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech translation configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithSubscription:(nonnull NSString *)subscriptionKey region:(nonnull NSString *)region error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes speech translation configuration with the specified subscription key and service region. |
||||
|
* |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token |
||||
|
* expires, the caller needs to refresh it by calling setAuthorizationToken with a new valid token on the created recognizer. |
||||
|
* Otherwise, the recognizer instance will encounter errors during recognition. |
||||
|
* For long-living recognizers, the authorization token needs to be updated on the recognizer. |
||||
|
* |
||||
|
* @param authToken the authorization token. |
||||
|
* @param region the region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). |
||||
|
* @return an instance of speech translation configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAuthorizationToken:(nonnull NSString *)authToken region:(nonnull NSString *)region |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes speech translation configuration with the specified subscription key and service region. |
||||
|
* |
||||
|
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token |
||||
|
* expires, the caller needs to refresh it by calling setAuthorizationToken with a new valid token on the created recognizer. |
||||
|
* Otherwise, the recognizer instance will encounter errors during recognition. |
||||
|
* For long-living recognizers, the authorization token needs to be updated on the recognizer. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param authToken the authorization token. |
||||
|
* @param region the region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech translation configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithAuthorizationToken:(nonnull NSString *)authToken region:(nonnull NSString *)region error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes speech translation configuration with specified endpoint and subscription key. |
||||
|
* This method is intended only for users who use a non-standard service endpoint or parameters. |
||||
|
* |
||||
|
* Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. |
||||
|
* For example, if the recognition language is defined in the URI as query parameter "language=de-DE", and is also set to "en-US" via |
||||
|
* property speechRecognitionLanguage in SPXSpeechTranslationConfiguration, the language setting in URI takes precedence, |
||||
|
* and the effective language is "de-DE". |
||||
|
* Only the parameters that are not specified in the endpoint URI can be set by other APIs. |
||||
|
* |
||||
|
* Note: To use an authorization token, use initWithEndpoint, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance. |
||||
|
* |
||||
|
* @param endpointUri The service endpoint to connect to. |
||||
|
* @param subscriptionKey the subscription key. |
||||
|
* @return an instance of speech translation configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEndpoint:(nonnull NSString *)endpointUri subscription:(nonnull NSString *)subscriptionKey |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes speech translation configuration with specified endpoint and subscription key. |
||||
|
* This method is intended only for users who use a non-standard service endpoint or parameters. |
||||
|
* |
||||
|
* Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. |
||||
|
* For example, if the recognition language is defined in the URI as query parameter "language=de-DE", and is also set to "en-US" via |
||||
|
* property speechRecognitionLanguage in SPXSpeechTranslationConfiguration, the language setting in URI takes precedence, |
||||
|
* and the effective language is "de-DE". |
||||
|
* Only the parameters that are not specified in the endpoint URI can be set by other APIs. |
||||
|
* |
||||
|
* Note: To use an authorization token, use initWithEndpoint, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance. |
||||
|
* |
||||
|
* Added in version 1.6.0. |
||||
|
* |
||||
|
* @param endpointUri The service endpoint to connect to. |
||||
|
* @param subscriptionKey the subscription key. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech translation configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEndpoint:(nonnull NSString *)endpointUri subscription:(nonnull NSString *)subscriptionKey error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes speech translation configuration with specified endpoint. |
||||
|
* This method is intended only for users who use a non-standard service endpoint or parameters. |
||||
|
* |
||||
|
* Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. |
||||
|
* For example, if the recognition language is defined in the URI as query parameter "language=de-DE", and is also set to "en-US" via |
||||
|
* property speechRecognitionLanguage in SPXSpeechTranslationConfiguration, the language setting in URI takes precedence, |
||||
|
* and the effective language is "de-DE". |
||||
|
* Only the parameters that are not specified in the endpoint URI can be set by other APIs. |
||||
|
* |
||||
|
* Note: if the endpoint requires a subscription key for authentication, please use initWithEndpoint:subscription: to pass the subscription key as parameter. |
||||
|
* To use an authorization token, use this method to create a SPXSpeechTranslationConfig instance, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance. |
||||
|
* |
||||
|
* Note: Added in version 1.5.0. |
||||
|
* |
||||
|
* @param endpointUri The service endpoint to connect to. |
||||
|
* @return an instance of speech translation configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEndpoint:(nonnull NSString *)endpointUri |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes speech translation configuration with specified endpoint. |
||||
|
* This method is intended only for users who use a non-standard service endpoint or parameters. |
||||
|
* |
||||
|
* Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. |
||||
|
* For example, if the recognition language is defined in the URI as query parameter "language=de-DE", and is also set to "en-US" via |
||||
|
* property speechRecognitionLanguage in SPXSpeechTranslationConfiguration, the language setting in URI takes precedence, |
||||
|
* and the effective language is "de-DE". |
||||
|
* Only the parameters that are not specified in the endpoint URI can be set by other APIs. |
||||
|
* |
||||
|
* Note: if the endpoint requires a subscription key for authentication, please use initWithEndpoint:subscription: to pass the subscription key as parameter. |
||||
|
* To use an authorization token, use this method to create a SPXSpeechTranslationConfig instance, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance. |
||||
|
* |
||||
|
* Note: Added in version 1.6.0. |
||||
|
* |
||||
|
* @param endpointUri The service endpoint to connect to. |
||||
|
* @param outError error information. |
||||
|
* @return an instance of speech translation configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithEndpoint:(nonnull NSString *)endpointUri error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes speech translation configuration with specified host and subscription key. |
||||
|
* This method is intended only for users who use a non-default service host. Standard resource path will be assumed. |
||||
|
* For services with a non-standard resource path or no path at all, use initWithEndpoint instead. |
||||
|
* |
||||
|
* Note: Query parameters are not allowed in the host URI and must be set by other APIs. |
||||
|
* |
||||
|
* Note: To use an authorization token, use initWithHost, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance. |
||||
|
* |
||||
|
* Added in version 1.8.0. |
||||
|
* |
||||
|
* @param hostUri The service host to connect to. Format is "protocol://host:port" where ":port" is optional. |
||||
|
* @param subscriptionKey The subscription key. |
||||
|
* @return An instance of speech translation configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithHost:(nonnull NSString *)hostUri subscription:(nonnull NSString *)subscriptionKey |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes speech translation configuration with specified host and subscription key. |
||||
|
* This method is intended only for users who use a non-default service host. Standard resource path will be assumed. |
||||
|
* For services with a non-standard resource path or no path at all, use initWithEndpoint instead. |
||||
|
* |
||||
|
* Note: Query parameters are not allowed in the host URI and must be set by other APIs. |
||||
|
* |
||||
|
* Note: To use an authorization token, use initWithHost, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance. |
||||
|
* |
||||
|
* Added in version 1.8.0. |
||||
|
* |
||||
|
* @param hostUri The service host to connect to. Format is "protocol://host:port" where ":port" is optional. |
||||
|
* @param subscriptionKey The subscription key. |
||||
|
* @param outError Error information. |
||||
|
* @return An instance of speech translation configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithHost:(nonnull NSString *)hostUri subscription:(nonnull NSString *)subscriptionKey error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes speech translation configuration with specified host. |
||||
|
* This method is intended only for users who use a non-default service host. Standard resource path will be assumed. |
||||
|
* For services with a non-standard resource path or no path at all, use initWithEndpoint instead. |
||||
|
* |
||||
|
* Note: Query parameters are not allowed in the host URI and must be set by other APIs. |
||||
|
* |
||||
|
* Note: If the host requires a subscription key for authentication, use initWithHost:subscription: to pass the subscription key as parameter. |
||||
|
* To use an authorization token, use this method to create a SPXSpeechTranslationConfig instance, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance. |
||||
|
* |
||||
|
* Added in version 1.8.0. |
||||
|
* |
||||
|
* @param hostUri The service host to connect to. Format is "protocol://host:port" where ":port" is optional. |
||||
|
* @return An instance of speech translation configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithHost:(nonnull NSString *)hostUri |
||||
|
NS_SWIFT_UNAVAILABLE("Use the method with Swift-compatible error handling."); |
||||
|
|
||||
|
/**
|
||||
|
* Initializes speech translation configuration with specified host. |
||||
|
* This method is intended only for users who use a non-default service host. Standard resource path will be assumed. |
||||
|
* For services with a non-standard resource path or no path at all, use initWithEndpoint instead. |
||||
|
* |
||||
|
* Note: Query parameters are not allowed in the host URI and must be set by other APIs. |
||||
|
* |
||||
|
* Note: If the host requires a subscription key for authentication, use initWithHost:subscription: to pass the subscription key as parameter. |
||||
|
* To use an authorization token, use this method to create a SPXSpeechTranslationConfig instance, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance. |
||||
|
* |
||||
|
* Added in version 1.8.0. |
||||
|
* |
||||
|
* @param hostUri The service host to connect to. Format is "protocol://host:port" where ":port" is optional. |
||||
|
* @param outError Error information. |
||||
|
* @return An instance of speech translation configuration. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithHost:(nonnull NSString *)hostUri error:(NSError * _Nullable * _Nullable)outError; |
||||
|
|
||||
|
/**
|
||||
|
* Adds a target language for translation. |
||||
|
* |
||||
|
* @param lang the language identifier in BCP-47 format. |
||||
|
*/ |
||||
|
- (void)addTargetLanguage:(nonnull NSString *)lang; |
||||
|
|
||||
|
/**
|
||||
|
* Removes a target language for translation. |
||||
|
* |
||||
|
* Added in version 1.7.0. |
||||
|
* |
||||
|
* @param lang the language identifier in BCP-47 format. |
||||
|
*/ |
||||
|
- (void)removeTargetLanguage:(nonnull NSString *)lang; |
||||
|
|
||||
|
/**
|
||||
|
* Sets a Category Id that will be passed to service. Category Id is used to find the custom model. |
||||
|
* |
||||
|
* @param categoryId the category id for custom model. |
||||
|
*/ |
||||
|
- (void)setCustomModelCategoryId:(nonnull NSString *)categoryId; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,55 @@ |
|||||
|
///
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represents information about a speech translation model. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSpeechTranslationModelInfo : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The name of the speech translation model. |
||||
|
*/ |
||||
|
@property (nonatomic, readonly, nonnull) NSString *name; |
||||
|
|
||||
|
/**
|
||||
|
* The source languages supported by the model. |
||||
|
*/ |
||||
|
@property (nonatomic, readonly, nonnull) NSArray<NSString *> *sourceLanguages; |
||||
|
|
||||
|
/**
|
||||
|
* The target languages supported by the model. |
||||
|
*/ |
||||
|
@property (nonatomic, readonly, nonnull) NSArray<NSString *> *targetLanguages; |
||||
|
|
||||
|
/**
|
||||
|
* The path of the model (valid only for offline models). |
||||
|
*/ |
||||
|
@property (nonatomic, readonly, nullable) NSString *path; |
||||
|
|
||||
|
/**
|
||||
|
* The version of the speech translation model. |
||||
|
*/ |
||||
|
@property (nonatomic, readonly, nonnull) NSString *version; |
||||
|
|
||||
|
/**
|
||||
|
* Initializes a new instance of the SPXSpeechTranslationModelInfo class. |
||||
|
* |
||||
|
* @param name The name of the model. |
||||
|
* @param sourceLanguages The source languages supported by the model. |
||||
|
* @param targetLanguages The target languages supported by the model. |
||||
|
* @param path The path of the model (valid only for offline models). |
||||
|
* @param version The version of the model. |
||||
|
* @return An initialized SPXSpeechTranslationModelInfo instance. |
||||
|
*/ |
||||
|
- (nullable instancetype)initWithName:(nonnull NSString *)name |
||||
|
sourceLanguages:(nonnull NSArray<NSString *> *)sourceLanguages |
||||
|
targetLanguages:(nonnull NSArray<NSString *> *)targetLanguages |
||||
|
path:(nullable NSString *)path |
||||
|
version:(nonnull NSString *)version; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,44 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXSpeechEnums.h" |
||||
|
#import "SPXPropertyCollection.h" |
||||
|
#import "SPXVoiceInfo.h" |
||||
|
|
||||
|
/**
|
||||
|
* Contains detailed information about the retrieved synthesis voices list. |
||||
|
* |
||||
|
* Added in version 1.16.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSynthesisVoicesResult : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The retrieved voices list. |
||||
|
*/ |
||||
|
@property (nonatomic, retain, nonnull) NSArray<SPXVoiceInfo *> *voices; |
||||
|
|
||||
|
/**
|
||||
|
* The result identifier. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *resultId; |
||||
|
|
||||
|
/**
|
||||
|
* The reason the result was created. |
||||
|
*/ |
||||
|
@property (readonly)SPXResultReason reason; |
||||
|
|
||||
|
/**
|
||||
|
* The error details of the result. |
||||
|
*/ |
||||
|
@property (copy, readonly, nonnull)NSString *errorDetails; |
||||
|
|
||||
|
/**
|
||||
|
* The set of properties exposed in the result. |
||||
|
*/ |
||||
|
@property (readonly, nullable)id <SPXPropertyCollection> properties; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,135 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
|
||||
|
/**
|
||||
|
* Contains nbest phoneme information. |
||||
|
* |
||||
|
* Added in version 1.21.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXNBestPhoneme : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The phoneme. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *phoneme; |
||||
|
|
||||
|
/**
|
||||
|
* The score. |
||||
|
*/ |
||||
|
@property (readonly)double score; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Contains basic properties of timing result |
||||
|
* |
||||
|
* Added in version 1.21.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXTimingResult : NSObject |
||||
|
|
||||
|
/**
|
||||
|
* The time offset. |
||||
|
*/ |
||||
|
@property (readonly)NSTimeInterval offset; |
||||
|
|
||||
|
/**
|
||||
|
* The time duration. |
||||
|
*/ |
||||
|
@property (readonly)NSTimeInterval duration; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Contains phoneme level timing result |
||||
|
* |
||||
|
* Added in version 1.21.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXPhonemeLevelTimingResult : SPXTimingResult |
||||
|
|
||||
|
/**
|
||||
|
* The phoneme text. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *phoneme; |
||||
|
|
||||
|
/**
|
||||
|
* The score indicating the pronunciation accuracy of the given speech, which indicates |
||||
|
* how closely the phoneme match a native speaker's pronunciation |
||||
|
*/ |
||||
|
@property (readonly)double accuracyScore; |
||||
|
|
||||
|
/**
|
||||
|
* The list of nbest phonemes. |
||||
|
*/ |
||||
|
@property (nonatomic, retain, nullable) NSArray<SPXNBestPhoneme *> *nbestPhonemes; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Contains syllable level timing result |
||||
|
* |
||||
|
* Added in version 1.21.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXSyllableLevelTimingResult : SPXTimingResult |
||||
|
|
||||
|
/**
|
||||
|
* The syllable. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *syllable; |
||||
|
|
||||
|
/**
|
||||
|
* The grapheme. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *grapheme; |
||||
|
|
||||
|
/**
|
||||
|
* The score indicating the pronunciation accuracy of the given speech, which indicates |
||||
|
* how closely the syllable match a native speaker's pronunciation. |
||||
|
*/ |
||||
|
@property (readonly)double accuracyScore; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Contains word level timing result |
||||
|
* |
||||
|
* Added in version 1.21.0 |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXWordLevelTimingResult : SPXTimingResult |
||||
|
|
||||
|
/**
|
||||
|
* The word text. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *word; |
||||
|
|
||||
|
/**
|
||||
|
* The score indicating the pronunciation accuracy of the given speech, which indicates |
||||
|
* how closely the phonemes match a native speaker's pronunciation. |
||||
|
*/ |
||||
|
@property (readonly)double accuracyScore; |
||||
|
|
||||
|
/**
|
||||
|
* This value indicates whether a word is omitted, inserted or badly pronounced, compared to ReferenceText. |
||||
|
* Possible values are None (meaning no error on this word), Omission, Insertion and Mispronunciation. |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *errorType; |
||||
|
|
||||
|
/**
|
||||
|
* Phoneme level pronunciation assessment result |
||||
|
*/ |
||||
|
@property (nonatomic, retain, nullable) NSArray<SPXPhonemeLevelTimingResult *> *phonemes; |
||||
|
|
||||
|
/**
|
||||
|
* Syllable level timing result |
||||
|
*/ |
||||
|
@property (nonatomic, retain, nullable) NSArray<SPXSyllableLevelTimingResult *> *syllables; |
||||
|
|
||||
|
@end |
||||
@ -0,0 +1,47 @@ |
|||||
|
//
|
||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
// See https://aka.ms/csspeech/license for the full license information.
|
||||
|
//
|
||||
|
|
||||
|
#import "SPXFoundation.h" |
||||
|
#import "SPXRecognitionEventArgs.h" |
||||
|
#import "SPXTranslationRecognitionResult.h" |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of text translation recognizing/recognized events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXTranslationRecognitionEventArgs : SPXRecognitionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* The translation text result. |
||||
|
*/ |
||||
|
@property (readonly, nonnull)SPXTranslationRecognitionResult *result; |
||||
|
|
||||
|
@end |
||||
|
|
||||
|
/**
|
||||
|
* Defines the payload of text translation canceled events. |
||||
|
*/ |
||||
|
SPX_EXPORT |
||||
|
@interface SPXTranslationRecognitionCanceledEventArgs : SPXTranslationRecognitionEventArgs |
||||
|
|
||||
|
/**
|
||||
|
* The reason why the text translation was canceled. |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationReason reason; |
||||
|
|
||||
|
/**
|
||||
|
* The error code in case of an unsuccessful recognition (reason is set to Error). |
||||
|
* |
||||
|
* Added in version 1.1.0. |
||||
|
*/ |
||||
|
@property (readonly)SPXCancellationErrorCode errorCode; |
||||
|
|
||||
|
/**
|
||||
|
* The error message in case of an unsuccessful recognition (reason is set to Error). |
||||
|
*/ |
||||
|
@property (copy, readonly, nullable)NSString *errorDetails; |
||||
|
|
||||
|
@end |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue