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

Incorporate this library into an OSX app with xcode #5

Closed
kunal732 opened this issue May 23, 2016 · 23 comments
Closed

Incorporate this library into an OSX app with xcode #5

kunal732 opened this issue May 23, 2016 · 23 comments

Comments

@kunal732
Copy link

Would love to incorporate this in a project im working on https://github.com/kunal732/MacLexa. Would it be possible to incorporate this into a swift mac app ?

@chenguoguo
Copy link
Collaborator

Hi,

We provide C++ libraries for Snowboy, so it's definitely possible to use Snowboy in swift. You can search for instructions of how to use C++ libraries in swift. For example, this page http://www.swiftprogrammer.info/swift_call_cpp.html. Basically you will have to write some simple wrappers for the C++ library.

Typically we use swig to generate wrappers for different programing languages. But swig probably doesn't support swift yet. In this case you may have to write the wrapper by yourself but it shouldn't be very complicated anyway. I'll post some examples of how to use Snowboy in C++ today (see #4), which might be helpful.

We would really appreciate it if you could help us looking into this direction, and possibly submit a pull request for your wrappers. Would like to see Snowboy in MacLexa, and we are ready to help if you have any questions!

Guoguo

@xuchen
Copy link
Collaborator

xuchen commented May 23, 2016

@kunal732 C++ example added: #7

Do you need extra help from here with the swift interface?

@flooie
Copy link

flooie commented Jun 3, 2016

I'm interested in building into an obj-c app that seems more doable yea?

@chenguoguo
Copy link
Collaborator

@flooie, that should be very easy. You can use the library under lib/ios/libsnowboy-detect.a (yes that's a fat library) and follow the C++ examples. It's basically same as using C++ library in Obj-C

@flooie
Copy link

flooie commented Jun 10, 2016

@chenguoguo I've taken a couple cracks at it - to no avail. Totally on my end. Any chance you have a good resource you can point me to online?

@flooie
Copy link

flooie commented Jun 10, 2016

@chenguoguo I also showed off snowboy to a cocoa heads boston last night.

@xuchen
Copy link
Collaborator

xuchen commented Jun 10, 2016

That's interesting. Did it work well in meetings? With Siri coming to the
Mac, it's more interesting we give people another choice in both trigger
word and the service behind it (AVS)
On Jun 10, 2016 6:33 AM, "flooie" notifications@github.com wrote:

@chenguoguo https://github.com/chenguoguo I also showed off snowboy to
a cocoa heads boston last night.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#5 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAhLO9YMkKBcn1AH3MuOz85UsQKvfwT-ks5qKWe-gaJpZM4IkHyy
.

@chenguoguo
Copy link
Collaborator

@flooie I felt it might be easier to give you an example, so I created this repo. I basically took Apple's aurioTouch sample code and modified it to have Snowboy hotword detection. You can compare the master branch and the snowboy branch to see what changes I have made to make it work. I mostly modified the file Classes/AudioController.mm. You should be able to run it from simulator.

Note that this setup is not optimized for hotword detection. And feel free to switch to other audio capturing tools if you have a preference. Let me know if you need more information on this.

@flooie
Copy link

flooie commented Jun 10, 2016

@chenguoguo this was helpful and validates what I was doing but I've mirrored (almost ) the project settings and can't get beyond this.

I'm using the compiled library in the OS X folder of the download.... any thoughts?

Undefined symbols for architecture x86_64:
"snowboy::SnowboyDetect::SnowboyDetect()", referenced from:
-[AppDelegate applicationDidFinishLaunching:] in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@flooie
Copy link

flooie commented Jun 10, 2016

thanks btw- you've gone above and beyond for me

@chenguoguo
Copy link
Collaborator

@flooie I think I've seen this yesterday. It was related to Xcode setting in my case. Initially I tried to add snowboy-detect.h and libsnowboy-detect.a through the 'Add Files to "auroiTouch"' option (which you can find through right click) and I think that error appeared. I then tried to create a directory called snowboy through the "New Group" option, and added snowboy-detect.h and libsnowboy-detect.a to that directory. I also changed the type of snowboy-detect.h to "C++ header" (through identity and type), location to "Relative to Group". For libsnowboy-detect.a I used type "Default - Data" and location "Relative to Group". That fixed the issue for me.

BTW, if you checkout out my repo (snowboy branch) and open the project directly, does it work for you? It works on my end.

@chenguoguo
Copy link
Collaborator

@flooie just saw this "I'm using the compiled library in the OS X folder of the download.... any thoughts?" Can you try to use the compiled library in the iOS folder? The library under the iOS folder is a fat library and contains library for x86_64 as well.

@flooie
Copy link

flooie commented Jun 11, 2016

@chenguoguo - I did check out the project and it does work on my computer. so i modeled everything based on that but haven't been able to get the OS X version to work.

@chenguoguo
Copy link
Collaborator

@flooie I suspect it's a configuration problem. Are you using Xcode to build your project? I tried to replace the iOS library with the OS X library in my example and it worked as well. So I think the library itself should be OK. Let us know if you get any progress on this.

@flooie
Copy link

flooie commented Jun 11, 2016

I am using Xcode and I thought I mirrored the settings pretty well - minus the iOS to OS X situation. - I'm gonna take another crack at it right now.

@flooie
Copy link

flooie commented Jun 11, 2016

I think I have success-

@chenguoguo
Copy link
Collaborator

Could you briefly let us know how you fix it?

@chenguoguo
Copy link
Collaborator

This info was not generated by the Snowboy library itself right? If you
feel there's too much of this kind of info, you can try to send the info
only when there's a status change.

Generally I would call the RunDetection() function every 0.01~0.1 second.
That's something you can play with. Higher frequency will lead to less
detection latency but also higher CPU usage. You can control this by using
some kind of sleep function. For example, in the Python demo we sleep for
0.03 second between each RunDetection() call.

On Sun, Jun 12, 2016 at 11:58 PM, flooie notifications@github.com wrote:

I'll happily share my code when I get it finished .

Now Ive got everything working and I'm detecting and sending information -
but I can't get beyond this

2016-06-12 11:56:32.251 Objcplusplus[26728:5473805] the result is 0
2016-06-12 11:56:32.263 Objcplusplus[26728:5473805] the result is 0
2016-06-12 11:56:32.274 Objcplusplus[26728:5473805] the result is 0
2016-06-12 11:56:32.286 Objcplusplus[26728:5473805] the result is 0
2016-06-12 11:56:32.297 Objcplusplus[26728:5473805] the result is 0
2016-06-12 11:56:32.309 Objcplusplus[26728:5473805] the result is 0
2016-06-12 11:56:32.321 Objcplusplus[26728:5473805] the result is 0
2016-06-12 11:56:32.332 Objcplusplus[26728:5473805] the result is 0
2016-06-12 11:56:32.345 Objcplusplus[26728:5473805] the result is -2
2016-06-12 11:56:32.355 Objcplusplus[26728:5473805] the result is -2
2016-06-12 11:56:32.366 Objcplusplus[26728:5473805] the result is -2
2016-06-12 11:56:32.378 Objcplusplus[26728:5473805] the result is -2
2016-06-12 11:56:32.390 Objcplusplus[26728:5473805] the result is -2
2016-06-12 11:56:32.401 Objcplusplus[26728:5473805] the result is -2
2016-06-12 11:56:32.413 Objcplusplus[26728:5473805] the result is -2
2016-06-12 11:56:32.425 Objcplusplus[26728:5473805] the result is -2
2016-06-12 11:56:32.436 Objcplusplus[26728:5473805] the result is -2
2016-06-12 11:56:32.448 Objcplusplus[26728:5473805] the result is -2
2016-06-12 11:56:32.459 Objcplusplus[26728:5473805] the result is -2
2016-06-12 11:56:32.471 Objcplusplus[26728:5473805] the result is -2
2016-06-12 11:56:32.483 Objcplusplus[26728:5473805] the result is -2

How fast should the loop be?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#5 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ALPfk2GbXd1iVH2h4gfbsoT4za3ygxKJks5qLCy0gaJpZM4IkHyy
.

@flooie
Copy link

flooie commented Jun 12, 2016

@chenguoguo mind if I share with you the project and you can take a gander?

@chenguoguo
Copy link
Collaborator

@flooie sure i can have a look

@flooie
Copy link

flooie commented Jun 13, 2016

@chenguoguo repo thanks -

@chenguoguo
Copy link
Collaborator

@flooie I cloned your repo and tried to build it with xcode, but I got the following error. What should I do to set up EZAudio properly? Or is it possible to set everything up in your repo?

ld: warning: directory not found for option '-L/Users/guoguo/Library/Developer/Xcode/DerivedData/Objcplusplus-ckypuogsetkktxggcfdknkvgjalc/Build/Products/Debug/EZAudio'
ld: warning: directory not found for option '-L/Users/guoguo/Library/Developer/Xcode/DerivedData/Objcplusplus-ckypuogsetkktxggcfdknkvgjalc/Build/Products/Debug/TPCircularBuffer'
ld: library not found for -lEZAudio
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@flooie
Copy link

flooie commented Jun 13, 2016

@chenguoguo Use Objcplusplus.xcworkspace - not xcodeproj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants