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

Added Swift SDK for Omi Dev Kit #972

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
38856a0
added readme
ashbhat Oct 4, 2024
da30110
added swift package to sdk
ashbhat Oct 4, 2024
0dfb26e
updated path to follow language
ashbhat Oct 4, 2024
a823008
added package.swift to root directory
ashbhat Oct 4, 2024
bc18838
added space to push package
ashbhat Oct 4, 2024
a0f23a3
removed package
ashbhat Oct 4, 2024
5ada89e
re added package
ashbhat Oct 4, 2024
03c7f1f
updated package file
ashbhat Oct 4, 2024
ce765de
removed package.swift from sdk folder
ashbhat Oct 4, 2024
2d2e809
removed foo (initial test code)
ashbhat Oct 4, 2024
15b5833
updated readme
ashbhat Oct 4, 2024
f2e8982
updated readme
ashbhat Oct 4, 2024
e1198b5
trying to move bundle outside of project to fix build issues
ashbhat Oct 4, 2024
be3a76f
testing moving bundle out
ashbhat Oct 4, 2024
7adf31a
trying different strategy to make bundle accessible
ashbhat Oct 4, 2024
38a78ab
going back to original build
ashbhat Oct 4, 2024
be67c6a
updated code to remove public variables
ashbhat Oct 4, 2024
f317fb8
Added private moniker to friendmanager class
ashbhat Oct 4, 2024
ccd7119
removed private moniker
ashbhat Oct 4, 2024
72bf3d9
made whisper optional and commented it out to see if this is functional
ashbhat Oct 4, 2024
2305d90
commented out live transcription for now
ashbhat Oct 4, 2024
0ee8b3c
exposing device id
ashbhat Oct 4, 2024
5a6ef42
added todo
ashbhat Oct 4, 2024
1b425f1
added reference to swift sdk in sdk readme
ashbhat Oct 4, 2024
a21258b
updated readme title
ashbhat Oct 4, 2024
bb9e944
recommented whisper back in
ashbhat Oct 4, 2024
8de5e9a
testing changing the resource directory
ashbhat Oct 4, 2024
3daf417
updated support for reosurces
ashbhat Oct 4, 2024
70fe22a
tried updating path
ashbhat Oct 4, 2024
224bb22
added support for live transcription
ashbhat Oct 4, 2024
fba26dd
Merge pull request #1 from ashbhat/whisper_tests
ashbhat Oct 4, 2024
5caf360
added sdks to readme
ashbhat Oct 4, 2024
b3449d1
fixed formatting
ashbhat Oct 4, 2024
b12165f
removed todo
ashbhat Oct 4, 2024
00abd35
added support for devkit 2
theashbhat Oct 5, 2024
26b8c59
update name to device.name
theashbhat Oct 5, 2024
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
37 changes: 37 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "omi-lib",
platforms: [
.iOS(.v17) // Set minimum version to iOS 17
],
products: [
.library(
name: "omi-lib",
targets: ["omi-lib"]
),
],
dependencies: [
// Add your dependency here
.package(url: "https://github.com/nelcea/swift-opus.git", from: "1.0.0"),
.package(url: "https://github.com/exPHAT/SwiftWhisper.git", branch: "fast"),
.package(url: "https://github.com/AudioKit/AudioKit.git", from: "5.6.4"),
],
targets: [
.target(
name: "omi-lib",
dependencies: [
.product(name: "Opus", package: "swift-opus"),
.product(name: "SwiftWhisper", package: "SwiftWhisper"),
.product(name: "AudioKit", package: "AudioKit"),
],
path: "sdks/swift", // Correct the path to your source files
resources: [
.process("Sources/omi-lib/Resources") // Make sure this resource is in the correct directory
]
),
]
)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ transcriptions of meetings, chats, and voice memos wherever you are.
- [Build the device](https://docs.omi.me/assembly/Build_the_device/)
- [Install firmware](https://docs.omi.me/assembly/Install_firmware/)
- [3rd Party Integrations](https://docs.omi.me/developer/plugins/Introduction/).

- [SDKs](sdks/README.md/)
## Contributions

* Check out our [contributions guide](https://docs.omi.me/developer/Contribution/).
Expand Down
6 changes: 6 additions & 0 deletions sdks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Omi SDKs

The Omi SDKs make it easy to build on top of omi in different languages

## Languages Supported:
– [Swift SDK](swift/README.md)
32 changes: 32 additions & 0 deletions sdks/swift/Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"pins" : [
{
"identity" : "audiokit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/AudioKit/AudioKit.git",
"state" : {
"revision" : "2ebd422855e4645d3169f83d1765d1c8196b4f46",
"version" : "5.6.4"
}
},
{
"identity" : "swift-opus",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nelcea/swift-opus.git",
"state" : {
"revision" : "a22f542387f1dd72c6c045ecc3b21dfed71acce2",
"version" : "1.0.0"
}
},
{
"identity" : "swiftwhisper",
"kind" : "remoteSourceControl",
"location" : "https://github.com/exPHAT/SwiftWhisper.git",
"state" : {
"branch" : "fast",
"revision" : "deb1cb6a27256c7b01f5d3d2e7dc1dcc330b5d01"
}
}
],
"version" : 2
}
88 changes: 88 additions & 0 deletions sdks/swift/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
### Omi Swift Library
An easy to install package to get started with the omi dev kit 1 in seconds.


## Installation
1. In Xcode navigate to File → Swift Packages → Add Package Dependency...
2. Select a project
3. Paste the repository URL (https://github.com/ashbhat/omi.git) and click Next.
4. For Rules, select Version (Up to Next Major) and click Next.
5. Click Finish.

## Requirements
iOS requires you to include Bluetooth permissions in the info.plist. This can be done by adding the following row
```xml
<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app needs Bluetooth access to connect to BLE devices.</string>
```

## Usage
The core interface for interacting with the Omi device is the **OmiManager.swift**. The OmiManager abstracts things like scanning, connecting, and reading bluetooth data into a few simple function calls.

**Looking for a device**
```swift
import omi_lib

func lookForDevice() {
OmiManager.startScan { device, error in
// connect to first found omi device
if let device = device {
print("got device ", device)
self.connectToOmiDevice(device: device)
OmiManager.endScan()
}
}
}

func lookForSpecificDevice(device_id: String) {
OmiManager.startScan { device, error in
// connect to first found omi device
if let device = device, device.id == "some_device_id" {
print("got device ", device)
self.connectToOmiDevice(device: device)
OmiManager.endScan()
}
}
}
```

**Connecting / Reconnecting to a device**
```swift
func connectToOmiDevice(device: Device) {
OmiManager.connectToDevice(device: device)
self.reconnectIfDisconnects()
}

func reconnectIfDisconnects() {
OmiManager.connectionUpdated { connected in
if connected == false {
self.lookForDevice()
}
}
}
```

**Getting Live Data**
```swift
func listenToLiveTranscript(device: Device) {
OmiManager.getLiveTranscription(device: device) { transcription in
print("transcription:", transcription ?? "no transcription")
}
}

func listenToLiveAudio(device: Device) {
OmiManager.getLiveAudio(device: device) { file_url in
print("file_url: ", file_url?.absoluteString ?? "no url")
}
}
```

## Licensing

Omi's Swift SDK is available under MIT License

### Third-Party Code

An excerpt of code from the PAL project, licensed under the MIT License, is used in this project. The original code can be found at: [nelcea/PAL](https://github.com/nelcea/PAL).

- Copyright (c) 2024 Nelcea
Loading