18EF69512C45130200AA0A36 /* IBAiManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EF69502C45130200AA0A36 /* IBAiManager.swift */; };
18EF69532C45136800AA0A36 /* IBPairling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EF69522C45136800AA0A36 /* IBPairling.swift */; };
18EF69552C45266D00AA0A36 /* IBReceiveManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EF69542C45266D00AA0A36 /* IBReceiveManager.swift */; };
- 18EF696F2C47983200AA0A36 /* MixSdk.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18EF696E2C47983200AA0A36 /* MixSdk.framework */; };
18EF69702C4798BB00AA0A36 /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 18EF696B2C47766400AA0A36 /* libbz2.tbd */; };
18EF69712C4798C600AA0A36 /* libiconv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 18EF69692C47765800AA0A36 /* libiconv.tbd */; };
18EF69722C4798D100AA0A36 /* liblzma.5.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 18EF69672C47764400AA0A36 /* liblzma.5.tbd */; };
18EF69672C47764400AA0A36 /* liblzma.5.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = liblzma.5.tbd; path = usr/lib/liblzma.5.tbd; sourceTree = SDKROOT; };
18EF69692C47765800AA0A36 /* libiconv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.tbd; path = usr/lib/libiconv.tbd; sourceTree = SDKROOT; };
18EF696B2C47766400AA0A36 /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; };
- 18EF696E2C47983200AA0A36 /* MixSdk.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = MixSdk.framework; sourceTree = "<group>"; };
18EF69752C47A0F200AA0A36 /* AIAudio.sbc */ = {isa = PBXFileReference; lastKnownFileType = file; path = AIAudio.sbc; sourceTree = "<group>"; };
18EF69782C47A86D00AA0A36 /* IBTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBTools.swift; sourceTree = "<group>"; };
18EFF59A2C080F14001B1E0E /* IBUserInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBUserInfo.swift; sourceTree = "<group>"; };
18EF69722C4798D100AA0A36 /* liblzma.5.tbd in Frameworks */,
18EF69712C4798C600AA0A36 /* libiconv.tbd in Frameworks */,
18EF69702C4798BB00AA0A36 /* libbz2.tbd in Frameworks */,
- 18EF696F2C47983200AA0A36 /* MixSdk.framework in Frameworks */,
8A0A39C92B980CC2006A3B18 /* CoreBluetooth.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
8A0A39BD2B980BEF006A3B18 /* IOTBluetooth */ = {
isa = PBXGroup;
children = (
- 18EF696E2C47983200AA0A36 /* MixSdk.framework */,
8A9F6ABF2BA04B5100DA520F /* Models */,
8A0A39D02B980DFD006A3B18 /* Tools */,
8A0A39C52B980C88006A3B18 /* IBluetooth.swift */,
//
import Foundation
-import MixSdk
+//import MixSdk
class IBAiManager{
static let shared = IBAiManager()
var audioData = Data()
var reply = ""
init(){
-// loginAction()
setupChatCallBack()
}
}
extension IBAiManager{
func loginAction() {
- MixSdk.shared.isDebug = true
- let deviceId = "281106AFB0F7"
- let productKey = "HHosiYUNdG42t1cTgKOzIUPOvAVMI2QT"
- let password = "F1xdqQL2fXjcmD4dV4To42dUUiBb2L"//注册获得的密码
-
- MixSdk.shared.auth.login(productKey:productKey,deviceId: deviceId, password: password){ token,error in
- if let err = error{
- Logger.log(err)
- }
- else{
- Logger.log("token = \(token!)")
- }
- }
+// MixSdk.shared.isDebug = true
+// let deviceId = "281106AFB0F7"
+// let productKey = "HHosiYUNdG42t1cTgKOzIUPOvAVMI2QT"
+// let password = "F1xdqQL2fXjcmD4dV4To42dUUiBb2L"//注册获得的密码
+//
+// MixSdk.shared.auth.login(productKey:productKey,deviceId: deviceId, password: password){ token,error in
+// if let err = error{
+// Logger.log(err)
+// }
+// else{
+// Logger.log("token = \(token!)")
+// }
+// }
}
func receiveAiData(sbcData:Data){
- let pcmData = MSAudioConvert.sbcTopcm(sbcData)
- if pcmData.count == 0{
- Logger.log("sbc2pcm失败")
- let model = IBAiResponse()
- model.type = 0
- sendRelpy(model: model)
- return
- }
- guard let pcmPath = IBTools.saveToFile(data: pcmData) else {return}
- MixSdk.shared.stt.sentenceRecognize(filePath: pcmPath,format:"pcm",sample_rate:"16000",lang: "zh-cn") {[weak self] text, error in
- guard let self = self else {return}
- if let text = text,text.count > 0{
- Logger.log(text)
- let model = IBAiResponse()
- model.type = 1
- model.value = text
- sendRelpy(model: model)
-
- MixSdk.shared.chat.send(content: text)
- }
- else{
- Logger.log(error ?? "")
- let model = IBAiResponse()
- model.type = 0
- sendRelpy(model: model)
- }
- }
+// let pcmData = MSAudioConvert.sbcTopcm(sbcData)
+// if pcmData.count == 0{
+// Logger.log("sbc2pcm失败")
+// let model = IBAiResponse()
+// model.type = 0
+// sendRelpy(model: model)
+// return
+// }
+// guard let pcmPath = IBTools.saveToFile(data: pcmData) else {return}
+// MixSdk.shared.stt.sentenceRecognize(filePath: pcmPath,format:"pcm",sample_rate:"16000",lang: "zh-cn") {[weak self] text, error in
+// guard let self = self else {return}
+// if let text = text,text.count > 0{
+// Logger.log(text)
+// let model = IBAiResponse()
+// model.type = 1
+// model.value = text
+// sendRelpy(model: model)
+//
+// MixSdk.shared.chat.send(content: text)
+// }
+// else{
+// Logger.log(error ?? "")
+// let model = IBAiResponse()
+// model.type = 0
+// sendRelpy(model: model)
+// }
+// }
}
func setupChatCallBack(){
- let chat = MixSdk.shared.chat
- chat.callBack = {[weak self] model in
- guard let self = self else {return}
- print("\(model.type) : \(model.content ?? "")")
-
- if model.type == "start" {
- reply = ""
- }
- else if model.type == "end" {
- let model = IBAiResponse()
- model.type = 2
- model.value = reply
- sendRelpy(model: model)
- }
- else if model.type == "middle"{
- reply += model.content ?? ""
- }
- }
+// let chat = MixSdk.shared.chat
+// chat.callBack = {[weak self] model in
+// guard let self = self else {return}
+// print("\(model.type) : \(model.content ?? "")")
+//
+// if model.type == "start" {
+// reply = ""
+// }
+// else if model.type == "end" {
+// let model = IBAiResponse()
+// model.type = 2
+// model.value = reply
+// sendRelpy(model: model)
+// }
+// else if model.type == "middle"{
+// reply += model.content ?? ""
+// }
+// }
}
func sendRelpy(model:IBAiResponse){