-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,591 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Swift Codestyle | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- '**/*.swift' | ||
pull_request: | ||
branches: [ main, 'v[0-9]+.[0-9]+' ] | ||
paths: | ||
- '**/*.swift' | ||
|
||
jobs: | ||
check-switch-codestyle: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Check swift codestyle | ||
uses: norio-nomura/action-swiftlint@3.2.1 | ||
with: | ||
args: lint --config res/.lint/swift/.swiftlint.yml --strict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Exclude the build directory | ||
build/* | ||
|
||
# Exclude temp nibs and swap files | ||
*~.nib | ||
*.swp | ||
|
||
# Exclude OS X folder attributes | ||
.DS_Store | ||
|
||
# Exclude user-specific XCode 3 and 4 files | ||
*.mode1 | ||
*.mode1v3 | ||
*.mode2v3 | ||
*.perspective | ||
*.perspectivev3 | ||
*.pbxuser | ||
*.xcworkspace | ||
project.xcworkspace | ||
contents.xcworkspacedata | ||
xcuserdata | ||
Pods |
450 changes: 450 additions & 0 deletions
450
recipes/llm-voice-assistant/ios/LLMVoiceAssistantDemo.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
95 changes: 95 additions & 0 deletions
95
...ios/LLMVoiceAssistantDemo.xcodeproj/xcshareddata/xcschemes/LLMVoiceAssistantDemo.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1530" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "02A11944268D39A700A2AC99" | ||
BuildableName = "LLMVoiceAssistantDemo.app" | ||
BlueprintName = "LLMVoiceAssistantDemo" | ||
ReferencedContainer = "container:LLMVoiceAssistantDemo.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "C7969FC426F53FBB0013DD41" | ||
BuildableName = "LLMVoiceAssistantDemoUITests.xctest" | ||
BlueprintName = "LLMVoiceAssistantDemoUITests" | ||
ReferencedContainer = "container:LLMVoiceAssistantDemo.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "02A11944268D39A700A2AC99" | ||
BuildableName = "LLMVoiceAssistantDemo.app" | ||
BlueprintName = "LLMVoiceAssistantDemo" | ||
ReferencedContainer = "container:LLMVoiceAssistantDemo.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
<EnvironmentVariables> | ||
<EnvironmentVariable | ||
key = "APP_ID" | ||
value = "G+s1i6gv9HGe0e0y0WPWwFmC+ShUrjTIce2XJWFbeBiOcJ1B/2wCuQ==" | ||
isEnabled = "YES"> | ||
</EnvironmentVariable> | ||
</EnvironmentVariables> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "02A11944268D39A700A2AC99" | ||
BuildableName = "LLMVoiceAssistantDemo.app" | ||
BlueprintName = "LLMVoiceAssistantDemo" | ||
ReferencedContainer = "container:LLMVoiceAssistantDemo.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
116 changes: 116 additions & 0 deletions
116
...oice-assistant/ios/LLMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"size" : "20x20", | ||
"idiom": "iphone", | ||
"filename" : "pv_circle_512-20@2x.png", | ||
"scale": "2x" | ||
}, | ||
{ | ||
"size" : "20x20", | ||
"idiom": "iphone", | ||
"filename" : "pv_circle_512-20@3x.png", | ||
"scale": "3x" | ||
}, | ||
{ | ||
"size" : "20x20", | ||
"idiom": "ipad", | ||
"filename" : "pv_circle_512-20.png", | ||
"scale": "1x" | ||
}, | ||
{ | ||
"size" : "20x20", | ||
"idiom": "ipad", | ||
"filename" : "pv_circle_512-20@2x.png", | ||
"scale": "2x" | ||
}, | ||
{ | ||
"size" : "29x29", | ||
"idiom" : "iphone", | ||
"filename" : "pv_circle_512-29@2x.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "29x29", | ||
"idiom" : "iphone", | ||
"filename" : "pv_circle_512-29@3x.png", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"size" : "40x40", | ||
"idiom" : "iphone", | ||
"filename" : "pv_circle_512-40@2x.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "40x40", | ||
"idiom" : "iphone", | ||
"filename" : "pv_circle_512-40@3x.png", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"size" : "60x60", | ||
"idiom" : "iphone", | ||
"filename" : "pv_circle_512-60@2x.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "60x60", | ||
"idiom" : "iphone", | ||
"filename" : "pv_circle_512-60@3x.png", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"size" : "29x29", | ||
"idiom" : "ipad", | ||
"filename" : "pv_circle_512-29.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"size" : "29x29", | ||
"idiom" : "ipad", | ||
"filename" : "pv_circle_512-29@2x.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "40x40", | ||
"idiom" : "ipad", | ||
"filename" : "pv_circle_512-40.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"size" : "40x40", | ||
"idiom" : "ipad", | ||
"filename" : "pv_circle_512-40@2x.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "76x76", | ||
"idiom" : "ipad", | ||
"filename" : "pv_circle_512-76.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"size" : "76x76", | ||
"idiom" : "ipad", | ||
"filename" : "pv_circle_512-76@2x.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "83.5x83.5", | ||
"idiom" : "ipad", | ||
"filename" : "pv_circle_512-83.5@2x.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "1024x1024", | ||
"idiom" : "ios-marketing", | ||
"filename" : "pv_circle_512-1024.png", | ||
"scale" : "1x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+37.9 KB
...LLMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.92 KB
...s/LLMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.93 KB
...LMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-20@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.88 KB
...LMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-20@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.38 KB
...s/LLMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-29.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.74 KB
...LMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-29@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.38 KB
...LMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-29@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.93 KB
...s/LLMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.96 KB
...LMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-40@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.3 KB
...LMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-40@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.3 KB
...LMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-60@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.8 KB
...LMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-60@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.71 KB
...s/LLMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.18 KB
...LMVoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-76@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.1 KB
...VoiceAssistantDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-83.5@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions
87
recipes/llm-voice-assistant/ios/LLMVoiceAssistantDemo/AudioPlayerStream.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// Copyright 2024 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 | ||
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
// | ||
|
||
import Foundation | ||
import AVFoundation | ||
|
||
class AudioPlayerStream { | ||
private let engine = AVAudioEngine() | ||
private let playerNode = AVAudioPlayerNode() | ||
private let mixerNode = AVAudioMixerNode() | ||
|
||
private var pcmBuffers = [AVAudioPCMBuffer]() | ||
public var isPlaying = false | ||
|
||
init(sampleRate: Double) throws { | ||
let audioSession = AVAudioSession.sharedInstance() | ||
try audioSession.setCategory(.playback, mode: .default) | ||
try audioSession.setActive(true) | ||
|
||
let format = AVAudioFormat( | ||
commonFormat: .pcmFormatFloat32, | ||
sampleRate: sampleRate, | ||
channels: AVAudioChannelCount(1), | ||
interleaved: false) | ||
|
||
engine.attach(mixerNode) | ||
engine.connect(mixerNode, to: engine.outputNode, format: format) | ||
|
||
engine.attach(playerNode) | ||
engine.connect(playerNode, to: mixerNode, format: format) | ||
|
||
try engine.start() | ||
} | ||
|
||
func playStreamPCM(_ pcmData: [Int16], completion: @escaping (Bool) -> Void) { | ||
let audioBuffer = AVAudioPCMBuffer( | ||
pcmFormat: playerNode.outputFormat(forBus: 0), frameCapacity: AVAudioFrameCount(pcmData.count))! | ||
|
||
audioBuffer.frameLength = audioBuffer.frameCapacity | ||
let buf = audioBuffer.floatChannelData![0] | ||
for (index, sample) in pcmData.enumerated() { | ||
var convertedSample = Float32(sample) / Float32(Int16.max) | ||
if convertedSample > 1 { | ||
convertedSample = 1 | ||
} | ||
if convertedSample < -1 { | ||
convertedSample = -1 | ||
} | ||
buf[index] = convertedSample | ||
} | ||
|
||
pcmBuffers.append(audioBuffer) | ||
if !isPlaying { | ||
playNextPCMBuffer(completion: completion) | ||
} else { | ||
completion(true) | ||
} | ||
} | ||
|
||
private func playNextPCMBuffer(completion: @escaping (Bool) -> Void) { | ||
guard let pcmData = pcmBuffers.first else { | ||
isPlaying = false | ||
completion(false) | ||
return | ||
} | ||
pcmBuffers.removeFirst() | ||
|
||
playerNode.scheduleBuffer(pcmData) { [weak self] in | ||
self?.playNextPCMBuffer(completion: completion) | ||
} | ||
|
||
playerNode.play() | ||
isPlaying = true | ||
completion(true) | ||
} | ||
|
||
func stopStreamPCM() { | ||
playerNode.stop() | ||
engine.stop() | ||
} | ||
} |
Oops, something went wrong.