Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.0 ios #676

Merged
merged 11 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/ios-swiftui/BaristaDemo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct ContentView: View {
.frame(minWidth: 0, maxWidth: UIScreen.main.bounds.width - 50)
.font(.body)
.opacity(viewModel.errorMessage.isEmpty ? 0 : 1)
.cornerRadius(.infinity)
.cornerRadius(10)
Text("Listening...")
.font(.body)
.foregroundColor(activeBlue)
Expand Down
4 changes: 2 additions & 2 deletions demo/ios-swiftui/BaristaDemo/ViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ViewModel: ObservableObject {

init() {
do {
picovoiceManager = PicovoiceManager(
picovoiceManager = try PicovoiceManager(
accessKey: ACCESS_KEY,
keywordPath: keywordPath!,
onWakeWordDetection: {
Expand Down Expand Up @@ -89,7 +89,7 @@ class ViewModel: ObservableObject {

try picovoiceManager.start()
} catch let error as PicovoiceInvalidArgumentError {
errorMessage = "\(error.localizedDescription)\nEnsure your AccessKey '\(ACCESS_KEY)' is valid"
errorMessage = "\(error.localizedDescription)"
} catch is PicovoiceActivationError {
errorMessage = "ACCESS_KEY activation error"
} catch is PicovoiceActivationRefusedError {
Expand Down
4 changes: 3 additions & 1 deletion demo/ios-swiftui/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ source 'https://cdn.cocoapods.org/'
platform :ios, '11.0'

target 'BaristaDemo' do
pod 'Picovoice-iOS', '~> 2.2.2'
pod 'Porcupine-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/porcupine/v3.0/binding/ios/Porcupine-iOS.podspec'
pod 'Rhino-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/rhino/v3.0/binding/ios/Rhino-iOS.podspec'
pod 'Picovoice-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/picovoice/v3.0-ios/sdk/ios/Picovoice-iOS.podspec'
end
33 changes: 20 additions & 13 deletions demo/ios-swiftui/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
PODS:
- ios-voice-processor (1.1.0)
- Picovoice-iOS (2.2.2):
- Picovoice-iOS (3.0.0):
- ios-voice-processor (~> 1.1.0)
- Porcupine-iOS (~> 2.2.1)
- Rhino-iOS (~> 2.2.2)
- Porcupine-iOS (2.2.1):
- Porcupine-iOS (~> 3.0.0)
- Rhino-iOS (~> 3.0.0)
- Porcupine-iOS (3.0.0):
- ios-voice-processor (~> 1.1.0)
- Rhino-iOS (2.2.2):
- Rhino-iOS (3.0.0):
- ios-voice-processor (~> 1.1.0)

DEPENDENCIES:
- Picovoice-iOS (~> 2.2.2)
- Picovoice-iOS (from `https://raw.githubusercontent.com/Picovoice/picovoice/v3.0-ios/sdk/ios/Picovoice-iOS.podspec`)
- Porcupine-iOS (from `https://raw.githubusercontent.com/Picovoice/porcupine/v3.0/binding/ios/Porcupine-iOS.podspec`)
- Rhino-iOS (from `https://raw.githubusercontent.com/Picovoice/rhino/v3.0/binding/ios/Rhino-iOS.podspec`)

SPEC REPOS:
trunk:
- ios-voice-processor
- Picovoice-iOS
- Porcupine-iOS
- Rhino-iOS

EXTERNAL SOURCES:
Picovoice-iOS:
:podspec: https://raw.githubusercontent.com/Picovoice/picovoice/v3.0-ios/sdk/ios/Picovoice-iOS.podspec
Porcupine-iOS:
:podspec: https://raw.githubusercontent.com/Picovoice/porcupine/v3.0/binding/ios/Porcupine-iOS.podspec
Rhino-iOS:
:podspec: https://raw.githubusercontent.com/Picovoice/rhino/v3.0/binding/ios/Rhino-iOS.podspec

SPEC CHECKSUMS:
ios-voice-processor: 8e32d7f980a06d392d128ef1cd19cf6ddcaca3c1
Picovoice-iOS: a0842f4d2320c32035425cb4aaa9aa095b9b0188
Porcupine-iOS: df8e4a63d787b6c16bd5f988fd0f2c29a249a4bd
Rhino-iOS: 0fad86b28d35f67ccb6bd0a2efbbcc0d88b05124
Picovoice-iOS: a1aefe4fbc54bb698dd1663d7dee6a5bef9f1c5c
Porcupine-iOS: 517158e02ac294dda15b713a3c6f74a9e877090c
Rhino-iOS: b92978104bfad32da25b9eeaa4f0628b86ffcee9

PODFILE CHECKSUM: 63d1720767824602e511ca46371fd9664d612c1d
PODFILE CHECKSUM: 8605c0181a885b936f6026ed64bb0ba6c7eddb0a

COCOAPODS: 1.11.3
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Picovoice Inc.
// Copyright 2021-2023 Picovoice Inc.
// You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
// file accompanying this source.
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
Expand Down Expand Up @@ -41,7 +41,7 @@ struct ContentView: View {
}

do {
self.picovoiceManager = PicovoiceManager(
self.picovoiceManager = try PicovoiceManager(
accessKey: self.ACCESS_KEY,
keywordPath: self.keywordPath!,
onWakeWordDetection: {
Expand Down Expand Up @@ -74,7 +74,7 @@ struct ContentView: View {
Sound.category = .playAndRecord
NotificationManager.shared.requestNotificationAuthorization()
} catch let error as PicovoiceInvalidArgumentError {
errorMessage = "\(error.localizedDescription)\nEnsure your AccessKey '\(ACCESS_KEY)' is valid"
errorMessage = "\(error.localizedDescription)"
} catch is PicovoiceActivationError {
errorMessage = "ACCESS_KEY activation error"
} catch is PicovoiceActivationRefusedError {
Expand Down Expand Up @@ -107,7 +107,7 @@ struct ContentView: View {
.frame(minWidth: 0, maxWidth: UIScreen.main.bounds.width - 50)
.font(.body)
.opacity(errorMessage.isEmpty ? 0 : 1)
.cornerRadius(.infinity)
.cornerRadius(10)

Spacer()
Text("""
Expand Down
4 changes: 3 additions & 1 deletion demo/ios/BackgroundService/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ source 'https://cdn.cocoapods.org/'
platform :ios, '11.0'

target 'PicovoiceBackgroundServiceDemo' do
pod 'Picovoice-iOS', '~> 2.2.2'
pod 'Porcupine-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/porcupine/v3.0/binding/ios/Porcupine-iOS.podspec'
pod 'Rhino-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/rhino/v3.0/binding/ios/Rhino-iOS.podspec'
pod 'Picovoice-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/picovoice/v3.0-ios/sdk/ios/Picovoice-iOS.podspec'
pod 'SwiftySound'
end
33 changes: 20 additions & 13 deletions demo/ios/BackgroundService/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
PODS:
- ios-voice-processor (1.1.0)
- Picovoice-iOS (2.2.2):
- Picovoice-iOS (3.0.0):
- ios-voice-processor (~> 1.1.0)
- Porcupine-iOS (~> 2.2.1)
- Rhino-iOS (~> 2.2.2)
- Porcupine-iOS (2.2.1):
- Porcupine-iOS (~> 3.0.0)
- Rhino-iOS (~> 3.0.0)
- Porcupine-iOS (3.0.0):
- ios-voice-processor (~> 1.1.0)
- Rhino-iOS (2.2.2):
- Rhino-iOS (3.0.0):
- ios-voice-processor (~> 1.1.0)
- SwiftySound (1.2.0)

DEPENDENCIES:
- Picovoice-iOS (~> 2.2.2)
- Picovoice-iOS (from `https://raw.githubusercontent.com/Picovoice/picovoice/v3.0-ios/sdk/ios/Picovoice-iOS.podspec`)
- Porcupine-iOS (from `https://raw.githubusercontent.com/Picovoice/porcupine/v3.0/binding/ios/Porcupine-iOS.podspec`)
- Rhino-iOS (from `https://raw.githubusercontent.com/Picovoice/rhino/v3.0/binding/ios/Rhino-iOS.podspec`)
- SwiftySound

SPEC REPOS:
trunk:
- ios-voice-processor
- Picovoice-iOS
- Porcupine-iOS
- Rhino-iOS
- SwiftySound

EXTERNAL SOURCES:
Picovoice-iOS:
:podspec: https://raw.githubusercontent.com/Picovoice/picovoice/v3.0-ios/sdk/ios/Picovoice-iOS.podspec
Porcupine-iOS:
:podspec: https://raw.githubusercontent.com/Picovoice/porcupine/v3.0/binding/ios/Porcupine-iOS.podspec
Rhino-iOS:
:podspec: https://raw.githubusercontent.com/Picovoice/rhino/v3.0/binding/ios/Rhino-iOS.podspec

SPEC CHECKSUMS:
ios-voice-processor: 8e32d7f980a06d392d128ef1cd19cf6ddcaca3c1
Picovoice-iOS: a0842f4d2320c32035425cb4aaa9aa095b9b0188
Porcupine-iOS: df8e4a63d787b6c16bd5f988fd0f2c29a249a4bd
Rhino-iOS: 0fad86b28d35f67ccb6bd0a2efbbcc0d88b05124
Picovoice-iOS: a1aefe4fbc54bb698dd1663d7dee6a5bef9f1c5c
Porcupine-iOS: 517158e02ac294dda15b713a3c6f74a9e877090c
Rhino-iOS: b92978104bfad32da25b9eeaa4f0628b86ffcee9
SwiftySound: 9eb28bb14edb601b40027e44319e0ef8383f88bf

PODFILE CHECKSUM: cf34b9eb6791109a69893ac260b5b87f99269465
PODFILE CHECKSUM: 3a5ea0fe8cae8a582022f3136ec9e681c2f81f3d

COCOAPODS: 1.11.3
82 changes: 38 additions & 44 deletions demo/ios/ForegroundApp/PicovoiceForegroundAppDemo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct ContentView: View {
@State var contextInfo: String = ""
@State var showInfo: Bool = false

func initPicovoice() {
func initPicovoice() -> Bool {
let keywordPath = Bundle.main.url(
forResource: "\(wakeword)_ios",
withExtension: "ppn",
Expand All @@ -60,8 +60,8 @@ struct ContentView: View {
forResource: "rhino_params_\(language)",
withExtension: "pv",
subdirectory: "models")!.path

self.picovoiceManager = PicovoiceManager(
do {
self.picovoiceManager = try PicovoiceManager(
accessKey: self.ACCESS_KEY,
keywordPath: keywordPath,
onWakeWordDetection: {
Expand Down Expand Up @@ -93,16 +93,40 @@ struct ContentView: View {
}
},
porcupineModelPath: ppnModelPath,
rhinoModelPath: rhnModelPath)
rhinoModelPath: rhnModelPath,
processErrorCallback: { error in
DispatchQueue.main.async {
errorMessage = "\(error)"
}
})
self.contextInfo = self.picovoiceManager.contextInfo
return true
} catch let error as PicovoiceInvalidArgumentError {
errorMessage = "\(error.localizedDescription)"
} catch is PicovoiceActivationError {
errorMessage = "ACCESS_KEY activation error"
} catch is PicovoiceActivationRefusedError {
errorMessage = "ACCESS_KEY activation refused"
} catch is PicovoiceActivationLimitError {
errorMessage = "ACCESS_KEY reached its limit"
} catch is PicovoiceActivationThrottledError {
errorMessage = "ACCESS_KEY is throttled"
} catch {
errorMessage = "\(error)"
}
return false
}

func startListening() {
self.textTimer?.invalidate()
self.result = ""
if self.picovoiceManager == nil {
self.initPicovoice()
guard initPicovoice() else {
return
}
}

self.textTimer?.invalidate()
self.result = ""

guard VoiceProcessor.hasRecordAudioPermission else {
VoiceProcessor.requestRecordAudioPermission { isGranted in
guard isGranted else {
Expand All @@ -119,32 +143,13 @@ struct ContentView: View {
return
}

if startPicovoice() {
self.buttonLabel = "STOP"
self.result = "Listening for '\(wakeword.uppercased())'..."
self.contextInfo = self.picovoiceManager.contextInfo
}
}

func startPicovoice() -> Bool {
do {
try self.picovoiceManager.start()
return true
} catch let error as PicovoiceInvalidArgumentError {
errorMessage =
"\(error.localizedDescription)\nEnsure your AccessKey '\(ACCESS_KEY)' is valid"
} catch is PicovoiceActivationError {
errorMessage = "ACCESS_KEY activation error"
} catch is PicovoiceActivationRefusedError {
errorMessage = "ACCESS_KEY activation refused"
} catch is PicovoiceActivationLimitError {
errorMessage = "ACCESS_KEY reached its limit"
} catch is PicovoiceActivationThrottledError {
errorMessage = "ACCESS_KEY is throttled"
self.buttonLabel = "STOP"
self.result = "Listening for '\(wakeword.uppercased())'..."
} catch {
errorMessage = "\(error)"
}
return false
}

func stopListening() {
Expand Down Expand Up @@ -174,7 +179,7 @@ struct ContentView: View {
.frame(minWidth: 0, maxWidth: UIScreen.main.bounds.width - 50)
.font(.body)
.opacity(errorMessage.isEmpty ? 0 : 1)
.cornerRadius(.infinity)
.cornerRadius(10)
Spacer()

Button {
Expand All @@ -197,23 +202,12 @@ struct ContentView: View {
.background(Color.white)
.navigationBarItems(trailing: Button("Context Info") {
if self.picovoiceManager == nil {
initPicovoice()
}
if self.picovoiceManager != nil {
if self.buttonLabel == "START" {
if self.startPicovoice() {
self.contextInfo = self.picovoiceManager.contextInfo
self.showInfo = true
do {
try self.picovoiceManager.stop()
} catch {
errorMessage = "\(error)"
}
}
} else {
self.showInfo = true
guard initPicovoice() else {
return
}
}

self.showInfo = true
})
}
.sheet(isPresented: self.$showInfo) {
Expand Down
4 changes: 3 additions & 1 deletion demo/ios/ForegroundApp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ source 'https://cdn.cocoapods.org/'
platform :ios, '11.0'

target 'PicovoiceForegroundAppDemo' do
pod 'Picovoice-iOS', '~> 2.2.2'
pod 'Porcupine-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/porcupine/v3.0/binding/ios/Porcupine-iOS.podspec'
pod 'Rhino-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/rhino/v3.0/binding/ios/Rhino-iOS.podspec'
pod 'Picovoice-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/picovoice/v3.0-ios/sdk/ios/Picovoice-iOS.podspec'
end
33 changes: 20 additions & 13 deletions demo/ios/ForegroundApp/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
PODS:
- ios-voice-processor (1.1.0)
- Picovoice-iOS (2.2.2):
- Picovoice-iOS (3.0.0):
- ios-voice-processor (~> 1.1.0)
- Porcupine-iOS (~> 2.2.1)
- Rhino-iOS (~> 2.2.2)
- Porcupine-iOS (2.2.1):
- Porcupine-iOS (~> 3.0.0)
- Rhino-iOS (~> 3.0.0)
- Porcupine-iOS (3.0.0):
- ios-voice-processor (~> 1.1.0)
- Rhino-iOS (2.2.2):
- Rhino-iOS (3.0.0):
- ios-voice-processor (~> 1.1.0)

DEPENDENCIES:
- Picovoice-iOS (~> 2.2.2)
- Picovoice-iOS (from `https://raw.githubusercontent.com/Picovoice/picovoice/v3.0-ios/sdk/ios/Picovoice-iOS.podspec`)
- Porcupine-iOS (from `https://raw.githubusercontent.com/Picovoice/porcupine/v3.0/binding/ios/Porcupine-iOS.podspec`)
- Rhino-iOS (from `https://raw.githubusercontent.com/Picovoice/rhino/v3.0/binding/ios/Rhino-iOS.podspec`)

SPEC REPOS:
trunk:
- ios-voice-processor
- Picovoice-iOS
- Porcupine-iOS
- Rhino-iOS

EXTERNAL SOURCES:
Picovoice-iOS:
:podspec: https://raw.githubusercontent.com/Picovoice/picovoice/v3.0-ios/sdk/ios/Picovoice-iOS.podspec
Porcupine-iOS:
:podspec: https://raw.githubusercontent.com/Picovoice/porcupine/v3.0/binding/ios/Porcupine-iOS.podspec
Rhino-iOS:
:podspec: https://raw.githubusercontent.com/Picovoice/rhino/v3.0/binding/ios/Rhino-iOS.podspec

SPEC CHECKSUMS:
ios-voice-processor: 8e32d7f980a06d392d128ef1cd19cf6ddcaca3c1
Picovoice-iOS: a0842f4d2320c32035425cb4aaa9aa095b9b0188
Porcupine-iOS: df8e4a63d787b6c16bd5f988fd0f2c29a249a4bd
Rhino-iOS: 0fad86b28d35f67ccb6bd0a2efbbcc0d88b05124
Picovoice-iOS: a1aefe4fbc54bb698dd1663d7dee6a5bef9f1c5c
Porcupine-iOS: 517158e02ac294dda15b713a3c6f74a9e877090c
Rhino-iOS: b92978104bfad32da25b9eeaa4f0628b86ffcee9

PODFILE CHECKSUM: 2fb6b93acd93b8e3eb769df53d60d93ebda1ae17
PODFILE CHECKSUM: ead49b51a70e3bec62b0e73975dc26dfb44c22a8

COCOAPODS: 1.11.3
1 change: 1 addition & 0 deletions resources/.lint/swift/.swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ disabled_rules:
- cyclomatic_complexity
- function_parameter_count
- type_body_length
- file_length
excluded:
- ${PWD}/**/Pods
- ${PWD}/**/node_modules
Expand Down
Loading