Skip to content

Commit

Permalink
Added setup and usage instructions to README
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinbjornt committed Jun 3, 2021
1 parent 3797f2c commit ea66742
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,50 @@
This repository contains the [Snowboy](https://github.com/seasalt-ai/snowboy)
hotword detection engine precompiled and packaged as an iOS framework.

The framework includes a Mach-O universal binary with 5 architectures:
i386, x86_64 arm_v7, arm_v7s and arm64.

## Setup

TBD
* Add Snowboy.framework to your target under General in Xcode.
* Also add Accelerate.framework, which is required by Snowboy
* Add common.res and a Snowboy model (either .pmdl or .umdl) to your application bundle

## Usage

TBD

### Create Snowboy detector C++ object instance

**Please note**: Any Objective-C source files using Snowboy must have the suffix `.mm`
to make sure they are compiled as Objective-C++.


```objc
NSString *commonPath = [[NSBundle mainBundle] pathForResource:@"common" ofType:@"res"];
NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"model" ofType:@"umdl"];

_snowboyDetect = new snowboy::SnowboyDetect(std::string([commonPath UTF8String]),
std::string([modelPath UTF8String]));
_snowboyDetect->SetSensitivity(0.5);
_snowboyDetect->SetAudioGain(1.0);
_snowboyDetect->ApplyFrontend(FALSE);
```
### Detect hotword in audio data
```objc
// ...Set up audio recording, one way or another
// Run detector on 16-bit audio samples
const int16_t *bytes = (int16_t *)[data bytes];
const int len = (int)[data length]/2;
int result = _snowboyDetect->RunDetection((const int16_t *)bytes, len);
if (result == 1) {
DLog(@"Snowboy: Hotword detected");
// Do something
}
```


## License

Expand All @@ -18,7 +55,7 @@ Snowboy is Copyright (C) 2016-2020 KITT.AI
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)

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
Expand Down

0 comments on commit ea66742

Please sign in to comment.