Closed Intiserahmed closed 3 weeks ago
The following is an example:
git clone https://github.com/k2-fsa/sherpa-onnx
cd sherpa-onnx
./build-swift-macos.sh
cd swift-api-examples
# there are several ./run-xxx.sh
# For instance,
./run-decode-file.sh
./run-tts.sh
@csukuangfj yeah i already run it, but how to use it with xcode project any example or hints please?
We have provided the required header file, libraries, and swift APIs.
Could you tell us the difficulty you have? Would be great if you can post error logs.
Hey @csukuangfj
I believe that what @Intiserahmed means is that there is example of how to use shepra-onnx in ios application, but there is no example of how to use it in MacOs(desktop) if it is even possible.
I am getting following error during build when I added framework from ios example to my MacOS desktop application
/.../Frameworks/sherpa-onnx.xcframework:1:1 While building for macOS, no library for this platform was found in '/../Frameworks/sherpa-onnx.xcframework'.
but there is no example of how to use it in MacOs(desktop) if it is even possible.
By the way, there is nothing special with sherpa-onnx.
For macOS app development, we provide shared libraries with C API header files.
The xcframework
is for iOS development only.
We do provide Swift API examples. Please see https://github.com/k2-fsa/sherpa-onnx/issues/1368#issuecomment-2365064156
Yeah, I see, but it is still not clear what I need to add and do with my xcode project in order to use shepra-onnx.
In other words - in one of the examples you have code like this:
var config = sherpaOnnxOfflineSpeakerDiarizationConfig(
segmentation: sherpaOnnxOfflineSpeakerSegmentationModelConfig(
pyannote: sherpaOnnxOfflineSpeakerSegmentationPyannoteModelConfig(model: segmentationModel)),
embedding: sherpaOnnxSpeakerEmbeddingExtractorConfig(model: embeddingExtractorModel),
clustering: sherpaOnnxFastClusteringConfig(numClusters: numSpeakers)
)
let sd = SherpaOnnxOfflineSpeakerDiarizationWrapper(config: &config)
What I need to add to xcode project in order to be able to use sherpaOnnxOfflineSpeakerDiarizationConfig
and other shepra-onnx functions. Thank you in advance.
(I am pretty new in ios/macos development and never used external non swift libraries/packages in my project, so maybe I am missing something trivial)
I am pretty new in ios/macos development and never used external non swift libraries/packages in my project,
In that case, I suggest that you first spend some time learning how to do that.
We have provided everything you need to be used in your macos project. You have to learn how to add which file to which place.
You may find https://k2-fsa.github.io/sherpa/ncnn/ios/for-the-more-curious-swift.html helpful, though you need to replace the xcframework with the shared library since the xcframework is for ios, not for macos.
@EnotPoloskun
Here is the xcframework for sherpa-onnx that supports both macos x86_64 and macos arm64.
To use it in your macos xcode project, please do the following:
Add the bridging header to your project
Add SherpaOnnx.swift to your project
Add sherpa-onnx.xcframework to your project
You can find it from https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-osx-universal2-static_lib-1.17.1.zip
Add -lc++
as the other linker flag
Done! Now you can use the Swift API of sherpa-onnx in your xcode project.
Please see how little code you need to write to set it up.
@csukuangfj Thanks a lot for the specific instructions.
@csukuangfj It worked like a charm first try. Really appreciate it. Thank you very much.
Hi, iOS is properly working, but when i try with MacOS build script with swift api examples, kindda confuse how to use it ? Any step by step guide for macos?