├── .clang-format ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ └── documentation.yml └── workflows │ ├── android-browserstack.yml │ ├── android-demos.yml │ ├── android-perf.yml │ ├── android-upload.yml │ ├── c-codestyle.yml │ ├── c-demos.yml │ ├── dotnet-codestyle.yml │ ├── dotnet-demos.yml │ ├── dotnet.yml │ ├── ios-browserstack.yml │ ├── ios-demos.yml │ ├── ios-perf.yml │ ├── java-codestyle.yml │ ├── link-check.yml │ ├── nodejs-codestyle.yml │ ├── nodejs-demos.yml │ ├── nodejs-perf.yml │ ├── nodejs.yml │ ├── python-codestyle.yml │ ├── python-demos.yml │ ├── python-perf.yml │ ├── python.yml │ ├── rust-codestyle.yml │ ├── rust-demos.yml │ ├── rust.yml │ ├── spell-check.yml │ ├── swift-codestyle.yml │ ├── web-codestyle.yml │ ├── web-demos.yml │ ├── web-perf.yml │ └── web.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── Package.swift ├── README.md ├── binding ├── android │ ├── Cobra │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── cobra │ │ │ ├── .gitignore │ │ │ ├── build.gradle │ │ │ ├── consumer-rules.pro │ │ │ ├── proguard-rules.pro │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── java │ │ │ │ └── ai │ │ │ │ │ └── picovoice │ │ │ │ │ └── cobra │ │ │ │ │ ├── Cobra.java │ │ │ │ │ ├── CobraNative.java │ │ │ │ │ └── exception │ │ │ │ │ ├── CobraActivationException.java │ │ │ │ │ ├── CobraActivationLimitException.java │ │ │ │ │ ├── CobraActivationRefusedException.java │ │ │ │ │ ├── CobraActivationThrottledException.java │ │ │ │ │ ├── CobraException.java │ │ │ │ │ ├── CobraIOException.java │ │ │ │ │ ├── CobraInvalidArgumentException.java │ │ │ │ │ ├── CobraInvalidStateException.java │ │ │ │ │ ├── CobraKeyException.java │ │ │ │ │ ├── CobraMemoryException.java │ │ │ │ │ ├── CobraRuntimeException.java │ │ │ │ │ └── CobraStopIterationException.java │ │ │ │ └── jniLibs │ │ │ │ └── .gitkeep │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── settings.gradle │ ├── CobraTestApp │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── cobra-test-app │ │ │ ├── .gitignore │ │ │ ├── build.gradle │ │ │ ├── proguard-rules.pro │ │ │ └── src │ │ │ │ ├── androidTest │ │ │ │ └── java │ │ │ │ │ └── ai │ │ │ │ │ └── picovoice │ │ │ │ │ └── cobra │ │ │ │ │ └── testapp │ │ │ │ │ ├── CobraTest.java │ │ │ │ │ ├── IntegrationTest.java │ │ │ │ │ └── PerformanceTest.java │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── ic_launcher-playstore.png │ │ │ │ ├── java │ │ │ │ └── ai │ │ │ │ │ └── picovoice │ │ │ │ │ └── cobra │ │ │ │ │ └── testapp │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── TestResult.java │ │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ ├── button_background.xml │ │ │ │ ├── button_disabled.xml │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ └── ic_launcher_foreground.xml │ │ │ │ ├── layout │ │ │ │ ├── activity_main.xml │ │ │ │ └── list_view.xml │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ │ └── values │ │ │ │ ├── colors.xml │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ ├── copy_test_resources.sh │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── settings.gradle │ └── README.md ├── dotnet │ ├── .editorconfig │ ├── .gitignore │ ├── Cobra.sln │ ├── Cobra │ │ ├── Cobra.cs │ │ ├── Cobra.csproj │ │ ├── Cobra.netstandard2.0.targets │ │ ├── Cobra.targets │ │ ├── CobraException.cs │ │ ├── Content │ │ │ └── pv_circle_512.png │ │ └── Utils.cs │ ├── CobraTest │ │ ├── CobraTest.csproj │ │ └── MainTest.cs │ └── README.md ├── ios │ ├── Cobra-iOS.podspec │ ├── Cobra.swift │ ├── CobraAppTest │ │ ├── .gitignore │ │ ├── CobraAppTest.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcshareddata │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ ├── CobraAppTest.xcscheme │ │ │ │ └── PerformanceTest.xcscheme │ │ ├── CobraAppTest │ │ │ ├── AppDelegate.swift │ │ │ ├── Assets.xcassets │ │ │ │ ├── AccentColor.colorset │ │ │ │ │ └── Contents.json │ │ │ │ ├── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ │ └── Contents.json │ │ │ ├── Base.lproj │ │ │ │ ├── LaunchScreen.storyboard │ │ │ │ └── Main.storyboard │ │ │ ├── Info.plist │ │ │ └── ViewController.swift │ │ ├── CobraAppTestUITests │ │ │ ├── CobraAppTestUITests.swift │ │ │ └── Info.plist │ │ └── PerformanceTest │ │ │ ├── Info.plist │ │ │ └── PerformanceTest.swift │ ├── CobraErrors.swift │ └── README.md ├── nodejs │ ├── .eslintignore │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmignore │ ├── .prettierignore │ ├── .prettierrc │ ├── README.md │ ├── copy.js │ ├── jest.config.js │ ├── package.json │ ├── src │ │ ├── cobra.ts │ │ ├── errors.ts │ │ ├── index.ts │ │ ├── platforms.ts │ │ ├── pv_status_t.ts │ │ ├── types.ts │ │ └── wave_util.ts │ ├── test │ │ ├── index.test.ts │ │ ├── perf.test.ts │ │ └── test_utils.ts │ ├── tsconfig.json │ └── yarn.lock ├── python │ ├── .gitignore │ ├── README.md │ ├── __init__.py │ ├── _cobra.py │ ├── _factory.py │ ├── _util.py │ ├── requirements.txt │ ├── setup.py │ ├── test_cobra.py │ ├── test_cobra_perf.py │ └── test_util.py ├── rust │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ ├── README.md │ ├── build.rs │ ├── copy.sh │ ├── src │ │ ├── cobra.rs │ │ ├── lib.rs │ │ └── util.rs │ ├── test.sh │ └── tests │ │ └── cobra_tests.rs └── web │ ├── .babelrc │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmignore │ ├── .prettierignore │ ├── .prettierrc │ ├── README.md │ ├── cypress.config.ts │ ├── cypress │ ├── fixtures │ │ └── .gitkeep │ ├── support │ │ ├── commands.ts │ │ ├── component-index.html │ │ └── index.ts │ └── tsconfig.json │ ├── lib │ └── .gitkeep │ ├── module.d.ts │ ├── package.json │ ├── rollup.config.js │ ├── scripts │ ├── copy_wasm.js │ └── setup_test.js │ ├── src │ ├── cobra.ts │ ├── cobra_errors.ts │ ├── cobra_worker.ts │ ├── cobra_worker_handler.ts │ ├── index.ts │ └── types.ts │ ├── test │ ├── cobra.test.ts │ └── cobra_perf.test.ts │ ├── tsconfig.json │ └── yarn.lock ├── demo ├── android │ ├── .gitignore │ ├── Activity │ │ ├── .gitignore │ │ ├── README.md │ │ ├── build.gradle │ │ ├── cobra-activity-demo-app │ │ │ ├── .gitignore │ │ │ ├── build.gradle │ │ │ ├── proguard-rules.pro │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── ic_launcher-playstore.png │ │ │ │ ├── java │ │ │ │ └── ai │ │ │ │ │ └── picovoice │ │ │ │ │ └── cobraactivitydemo │ │ │ │ │ ├── Gauge.java │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── Needle.java │ │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ ├── button_background.xml │ │ │ │ ├── button_disabled.xml │ │ │ │ ├── error_view.xml │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ └── ic_launcher_foreground.xml │ │ │ │ ├── layout │ │ │ │ └── cobra_activity_demo.xml │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ └── values │ │ │ │ ├── attrs.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ ├── copy_test_resources.sh │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── settings.gradle │ └── README.md ├── c │ ├── .gitignore │ ├── CMakeLists.txt │ ├── Preload.CMake │ ├── README.md │ ├── cobra_demo_file.c │ ├── cobra_demo_mic.c │ └── test │ │ ├── requirements.txt │ │ ├── test_cobra_c.py │ │ └── test_util.py ├── dotnet │ ├── .editorconfig │ ├── .gitignore │ ├── CobraDemo.sln │ ├── CobraDemo │ │ ├── CobraDemo.csproj │ │ ├── FileDemo.cs │ │ └── MicDemo.cs │ └── README.md ├── ios │ ├── .gitignore │ ├── CobraDemo │ │ ├── .gitignore │ │ ├── CobraDemo.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── CobraDemo.xcscheme │ │ └── CobraDemo │ │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── pv_circle_512-1024.png │ │ │ │ ├── pv_circle_512-20.png │ │ │ │ ├── pv_circle_512-20@2x.png │ │ │ │ ├── pv_circle_512-20@3x.png │ │ │ │ ├── pv_circle_512-29.png │ │ │ │ ├── pv_circle_512-29@2x.png │ │ │ │ ├── pv_circle_512-29@3x.png │ │ │ │ ├── pv_circle_512-40.png │ │ │ │ ├── pv_circle_512-40@2x.png │ │ │ │ ├── pv_circle_512-40@3x.png │ │ │ │ ├── pv_circle_512-60@2x.png │ │ │ │ ├── pv_circle_512-60@3x.png │ │ │ │ ├── pv_circle_512-76.png │ │ │ │ ├── pv_circle_512-76@2x.png │ │ │ │ └── pv_circle_512-83.5@2x.png │ │ │ ├── CobraDemoApp.swift │ │ │ ├── ContentView.swift │ │ │ ├── Info.plist │ │ │ └── ViewModel.swift │ └── README.md ├── nodejs │ ├── .gitignore │ ├── .npmignore │ ├── README.md │ ├── file.js │ ├── mic.js │ ├── package.json │ └── yarn.lock ├── python │ ├── .gitignore │ ├── README.md │ ├── cobra_demo_file.py │ ├── cobra_demo_mic.py │ ├── requirements.txt │ └── setup.py ├── rust │ ├── README.md │ ├── filedemo │ │ ├── .gitignore │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ │ └── main.rs │ └── micdemo │ │ ├── .gitignore │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ └── main.rs └── web │ ├── .gitignore │ ├── .npmignore │ ├── .prettierignore │ ├── .prettierrc │ ├── README.md │ ├── eslint.config.mjs │ ├── index.html │ ├── package.json │ ├── scripts │ └── cobra.js │ └── yarn.lock ├── include ├── picovoice.h └── pv_cobra.h ├── lib ├── android │ ├── arm64-v8a │ │ └── libpv_cobra.so │ ├── armeabi-v7a │ │ └── libpv_cobra.so │ ├── x86 │ │ └── libpv_cobra.so │ └── x86_64 │ │ └── libpv_cobra.so ├── ios │ └── PvCobra.xcframework │ │ ├── Info.plist │ │ ├── ios-arm64 │ │ └── PvCobra.framework │ │ │ ├── Headers │ │ │ ├── PvCobra.h │ │ │ ├── picovoice.h │ │ │ └── pv_cobra.h │ │ │ ├── Info.plist │ │ │ ├── Modules │ │ │ └── module.modulemap │ │ │ └── PvCobra │ │ └── ios-arm64_x86_64-simulator │ │ └── PvCobra.framework │ │ ├── Headers │ │ ├── PvCobra.h │ │ ├── picovoice.h │ │ └── pv_cobra.h │ │ ├── Info.plist │ │ ├── Modules │ │ └── module.modulemap │ │ └── PvCobra ├── linux │ └── x86_64 │ │ └── libpv_cobra.so ├── mac │ ├── arm64 │ │ └── libpv_cobra.dylib │ └── x86_64 │ │ └── libpv_cobra.dylib ├── node │ ├── linux │ │ └── x86_64 │ │ │ └── pv_cobra.node │ ├── mac │ │ ├── arm64 │ │ │ └── pv_cobra.node │ │ └── x86_64 │ │ │ └── pv_cobra.node │ ├── raspberry-pi │ │ ├── cortex-a53-aarch64 │ │ │ └── pv_cobra.node │ │ ├── cortex-a53 │ │ │ └── pv_cobra.node │ │ ├── cortex-a72-aarch64 │ │ │ └── pv_cobra.node │ │ ├── cortex-a72 │ │ │ └── pv_cobra.node │ │ ├── cortex-a76-aarch64 │ │ │ └── pv_cobra.node │ │ └── cortex-a76 │ │ │ └── pv_cobra.node │ └── windows │ │ ├── amd64 │ │ └── pv_cobra.node │ │ └── arm64 │ │ └── pv_cobra.node ├── raspberry-pi │ ├── arm11 │ │ └── libpv_cobra.so │ ├── cortex-a53-aarch64 │ │ └── libpv_cobra.so │ ├── cortex-a53 │ │ └── libpv_cobra.so │ ├── cortex-a72-aarch64 │ │ └── libpv_cobra.so │ ├── cortex-a72 │ │ └── libpv_cobra.so │ ├── cortex-a76-aarch64 │ │ └── libpv_cobra.so │ └── cortex-a76 │ │ └── libpv_cobra.so ├── wasm │ ├── pv_cobra.wasm │ └── pv_cobra_simd.wasm └── windows │ ├── amd64 │ └── libpv_cobra.dll │ └── arm64 │ └── libpv_cobra.dll ├── res ├── .lint │ ├── c │ │ └── formatter.py │ ├── java │ │ ├── checkstyle-10.5.0-all.jar │ │ ├── checkstyle.xml │ │ └── suppress.xml │ ├── spell-check │ │ ├── .cspell.json │ │ └── dict.txt │ └── swift │ │ └── .swiftlint.yml ├── audio │ └── sample.wav └── scripts │ └── machine-state.sh └── script └── automation └── browserstack.py /.gitattributes: -------------------------------------------------------------------------------- 1 | demo/** linguist-detectable=false 2 | lib/** linguist-detectable=false 3 | res/** linguist-detectable=false 4 | 5 | binding/android/** linguist-detectable=false 6 | binding/dotnet/CobraTest/** linguist-detectable=false 7 | binding/ios/CobraAppTest/** linguist-detectable=false 8 | binding/nodejs/** linguist-detectable=false 9 | binding/nodejs/src/cobra.ts linguist-detectable=true 10 | binding/rust/tests/** linguist-detectable=false 11 | binding/web/** linguist-detectable=false 12 | binding/web/src/cobra.ts linguist-detectable=true 13 | 14 | *.py linguist-detectable=true 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.yml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | description: Issues around documentation of Cobra 3 | title: "Cobra Documentation Issue: " 4 | labels: ["documentation"] 5 | body: 6 | - type: input 7 | id: url 8 | attributes: 9 | label: What is the URL of the doc? 10 | validations: 11 | required: true 12 | - type: textarea 13 | id: issue 14 | attributes: 15 | label: What is the nature of the issue? 16 | description: e.g. steps do not work, typos/grammar/spelling, out of date, etc. 17 | validations: 18 | required: true 19 | -------------------------------------------------------------------------------- /.github/workflows/android-demos.yml: -------------------------------------------------------------------------------- 1 | name: Android Demos 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - '.github/workflows/android-demos.yml' 9 | - 'demo/android/**' 10 | - '!demo/android/Activity/README.md' 11 | pull_request: 12 | branches: [ main, 'v[0-9]+.[0-9]+' ] 13 | paths: 14 | - '.github/workflows/android-demos.yml' 15 | - 'demo/android/**' 16 | - '!demo/android/Activity/README.md' 17 | 18 | jobs: 19 | build-activity-demo: 20 | runs-on: ubuntu-latest 21 | strategy: 22 | matrix: 23 | java-version: [11, 17, 21] 24 | include: 25 | - java-version: 11 26 | gradle-version: 6.5 27 | agp-version: 4.1.3 28 | - java-version: 17 29 | gradle-version: 7.5 30 | agp-version: 7.4.2 31 | - java-version: 21 32 | gradle-version: 8.5 33 | agp-version: 8.2.2 34 | 35 | defaults: 36 | run: 37 | working-directory: demo/android/Activity 38 | 39 | steps: 40 | - uses: actions/checkout@v3 41 | 42 | - name: Override gradle settings 43 | run: sed -i "s/com.android.tools.build:gradle:[0-9]*\.[0-9]*\.[0-9]*/com.android.tools.build:gradle:${{ matrix.agp-version }}/g" build.gradle 44 | 45 | - name: set up JDK ${{ matrix.java-version }} 46 | uses: actions/setup-java@v3 47 | with: 48 | java-version: ${{ matrix.java-version }} 49 | distribution: 'temurin' 50 | 51 | - name: Use Gradle ${{ matrix.gradle-version }} 52 | uses: gradle/actions/setup-gradle@v3 53 | with: 54 | gradle-version: ${{ matrix.gradle-version }} 55 | 56 | 57 | - name: Build 58 | run: gradle assembleDebug 59 | -------------------------------------------------------------------------------- /.github/workflows/android-upload.yml: -------------------------------------------------------------------------------- 1 | name: Android Upload 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - '.github/workflows/android-upload.yml' 9 | - 'demo/android/**/build.gradle' 10 | pull_request: 11 | branches: [ main, 'v[0-9]+.[0-9]+' ] 12 | paths: 13 | - '.github/workflows/android-upload.yml' 14 | - 'demo/android/Activity/**/build.gradle' 15 | 16 | jobs: 17 | upload-demo: 18 | runs-on: ubuntu-latest 19 | defaults: 20 | run: 21 | working-directory: demo/android/Activity 22 | 23 | steps: 24 | - uses: actions/checkout@v3 25 | 26 | - name: set up JDK 17 27 | uses: actions/setup-java@v3 28 | with: 29 | java-version: 17 30 | distribution: 'temurin' 31 | 32 | - name: Set up service json 33 | run: echo ${{secrets.GOOGLE_PLAY_SERVICE_JSON}} | base64 -d > ./service-account.json 34 | 35 | - name: Override version code 36 | run: | 37 | VC=`fastlane run google_play_track_version_codes \ 38 | json_key:"./service-account.json" \ 39 | package_name:"ai.picovoice.cobraactivitydemo" \ 40 | track:"internal" \ 41 | | grep -oP '(?<=Result: \[)\d+(?=\])' \ 42 | | awk '{print $1+1}'` 43 | sed -i "s/versionCode [0-9]*/versionCode $VC/g" cobra-activity-demo-app/build.gradle 44 | - name: Inject Android keystore variables 45 | run: | 46 | echo storePassword="${{secrets.ANDROID_RELEASE_KEYSTORE_PASSWORD}}" >> local.properties 47 | echo keyPassword="${{secrets.ANDROID_RELEASE_KEYSTORE_PASSWORD}}" >> local.properties 48 | echo keyAlias=picovoice >> local.properties 49 | echo storeFile=../picovoice.jks >> local.properties 50 | - name: Setup Android keystore file 51 | run: echo "${{secrets.ANDROID_RELEASE_KEYSTORE_FILE_B64}}" | base64 -d > picovoice.jks 52 | 53 | - name: Build 54 | run: ./gradlew bundleRelease 55 | 56 | - name: Upload to Google Play 57 | run: fastlane supply --json_key ./service-account.json --package_name ai.picovoice.cobraactivitydemo --aab cobra-activity-demo-app/build/outputs/bundle/release/cobra-activity-demo-app-release.aab --track internal --skip_upload_metadata --skip_upload_images --skip_upload_screenshots --release_status draft 58 | -------------------------------------------------------------------------------- /.github/workflows/c-codestyle.yml: -------------------------------------------------------------------------------- 1 | name: C Codestyle 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - '**/*.c' 9 | - '.github/workflows/c-codestyle.yml' 10 | pull_request: 11 | branches: [ main, 'v[0-9]+.[0-9]+' ] 12 | paths: 13 | - '**/*.c' 14 | - '.github/workflows/c-codestyle.yml' 15 | 16 | jobs: 17 | check-c-codestyle: 18 | runs-on: ubuntu-latest 19 | 20 | steps: 21 | - uses: actions/checkout@v3 22 | 23 | - name: Set up Python 3.10 24 | uses: actions/setup-python@v4 25 | with: 26 | python-version: '3.10' 27 | 28 | - name: Install dependencies 29 | run: sudo apt install clang-format 30 | 31 | - name: Check c codestyle 32 | run: python3 res/.lint/c/formatter.py -c -v -------------------------------------------------------------------------------- /.github/workflows/dotnet-codestyle.yml: -------------------------------------------------------------------------------- 1 | name: .NET Codestyle 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - 'binding/dotnet/**/*.cs' 9 | - 'demo/dotnet/**/*.cs' 10 | - '.github/workflows/dotnet-codestyle.yml' 11 | pull_request: 12 | branches: [ main, 'v[0-9]+.[0-9]+' ] 13 | paths: 14 | - 'binding/dotnet/**/*.cs' 15 | - 'demo/dotnet/**/*.cs' 16 | - '.github/workflows/dotnet-codestyle.yml' 17 | 18 | jobs: 19 | check-dotnet-codestyle: 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v3 24 | 25 | - name: Set up .NET 8.0 26 | uses: actions/setup-dotnet@v3 27 | with: 28 | dotnet-version: 8.0.x 29 | 30 | - name: Run Binding Codestyle 31 | run: dotnet format --verify-no-changes 32 | working-directory: binding/dotnet 33 | 34 | - name: Run Demo Codestyle 35 | run: dotnet format --verify-no-changes 36 | working-directory: demo/dotnet 37 | -------------------------------------------------------------------------------- /.github/workflows/dotnet-demos.yml: -------------------------------------------------------------------------------- 1 | name: .NET Demos 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - 'demo/dotnet/**' 9 | - '!demo/dotnet/README.md' 10 | - 'res/audio/**' 11 | - '.github/workflows/dotnet-demos.yml' 12 | pull_request: 13 | branches: [ main, 'v[0-9]+.[0-9]+' ] 14 | paths: 15 | - 'demo/dotnet/**' 16 | - '!demo/dotnet/README.md' 17 | - 'res/audio/**' 18 | - '.github/workflows/dotnet-demos.yml' 19 | 20 | defaults: 21 | run: 22 | working-directory: demo/dotnet/CobraDemo 23 | 24 | jobs: 25 | build-github-hosted: 26 | runs-on: ${{ matrix.os }} 27 | 28 | strategy: 29 | matrix: 30 | os: [ubuntu-latest, windows-latest, macos-latest] 31 | 32 | steps: 33 | - uses: actions/checkout@v3 34 | 35 | - name: Set up .NET 8.0 36 | uses: actions/setup-dotnet@v3 37 | with: 38 | dotnet-version: 8.0.x 39 | 40 | - name: Package restore 41 | run: dotnet restore 42 | 43 | - name: Dotnet build mic demo 44 | run: dotnet build -c MicDemo.Release 45 | 46 | - name: Dotnet build file demo 47 | run: dotnet build -c FileDemo.Release 48 | 49 | - name: Run Dotnet file demo 50 | run: dotnet run -c FileDemo.Release -- --input_audio_path ../../../res/audio/sample.wav --access_key ${{secrets.PV_VALID_ACCESS_KEY}} 51 | 52 | build-self-hosted: 53 | runs-on: ${{ matrix.machine }} 54 | 55 | strategy: 56 | matrix: 57 | machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, pv-windows-arm64] 58 | 59 | steps: 60 | - uses: actions/checkout@v3 61 | 62 | - name: Package restore 63 | run: dotnet restore 64 | 65 | - name: Dotnet build mic demo 66 | run: dotnet build -c MicDemo.Release 67 | 68 | - name: Dotnet build file demo 69 | run: dotnet build -c FileDemo.Release 70 | 71 | - name: Run Dotnet file demo 72 | run: dotnet run -c FileDemo.Release -- --input_audio_path ../../../res/audio/sample.wav --access_key ${{secrets.PV_VALID_ACCESS_KEY}} 73 | -------------------------------------------------------------------------------- /.github/workflows/ios-browserstack.yml: -------------------------------------------------------------------------------- 1 | name: iOS BrowserStack Tests 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - '.github/workflows/ios-browserstack.yml' 9 | - 'binding/ios/CobraAppTest/**' 10 | 11 | pull_request: 12 | branches: [ main, 'v[0-9]+.[0-9]+' ] 13 | paths: 14 | - '.github/workflows/ios-browserstack.yml' 15 | - 'binding/ios/CobraAppTest/**' 16 | 17 | 18 | defaults: 19 | run: 20 | working-directory: binding/ios/CobraAppTest 21 | 22 | jobs: 23 | build: 24 | name: Run iOS Tests on BrowserStack 25 | runs-on: macos-latest 26 | 27 | steps: 28 | - name: Checkout 29 | uses: actions/checkout@v3 30 | 31 | - name: Installing Python 32 | uses: actions/setup-python@v5 33 | with: 34 | python-version: '3.10' 35 | - run: 36 | pip3 install requests 37 | 38 | - name: Make build dir 39 | run: mkdir ddp 40 | 41 | - name: Inject AccessKey 42 | run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:' 43 | CobraAppTestUITests/CobraAppTestUITests.swift 44 | 45 | - name: XCode Build 46 | run: xcrun xcodebuild build-for-testing 47 | -configuration Debug 48 | -project CobraAppTest.xcodeproj 49 | -sdk iphoneos 50 | -scheme CobraAppTest 51 | -derivedDataPath ddp 52 | CODE_SIGNING_ALLOWED=NO 53 | 54 | - name: Generating ipa 55 | run: cd ddp/Build/Products/Debug-iphoneos/ && 56 | mkdir Payload && 57 | cp -r CobraAppTest.app Payload && 58 | zip --symlinks -r CobraAppTest.ipa Payload && 59 | rm -r Payload 60 | 61 | - name: Zipping Tests 62 | run: cd ddp/Build/Products/Debug-iphoneos/ && 63 | zip --symlinks -r CobraAppTestUITests.zip CobraAppTestUITests-Runner.app 64 | 65 | - name: Run tests on BrowserStack 66 | run: python3 ../../../script/automation/browserstack.py 67 | --type xcuitest 68 | --username "${{secrets.BROWSERSTACK_USERNAME}}" 69 | --access_key "${{secrets.BROWSERSTACK_ACCESS_KEY}}" 70 | --project_name "Cobra-iOS" 71 | --devices "ios-min-max" 72 | --app_path "ddp/Build/Products/Debug-iphoneos/CobraAppTest.ipa" 73 | --test_path "ddp/Build/Products/Debug-iphoneos/CobraAppTestUITests.zip" -------------------------------------------------------------------------------- /.github/workflows/ios-demos.yml: -------------------------------------------------------------------------------- 1 | name: iOS Demos 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - 'demo/ios/CobraDemo/**' 9 | - '.github/workflows/ios-demos.yml' 10 | pull_request: 11 | branches: [ main, 'v[0-9]+.[0-9]+' ] 12 | paths: 13 | - 'demo/ios/CobraDemo/**' 14 | - '.github/workflows/ios-demos.yml' 15 | 16 | defaults: 17 | run: 18 | working-directory: demo/ios/CobraDemo 19 | 20 | jobs: 21 | build: 22 | runs-on: macos-latest 23 | 24 | steps: 25 | - name: Checkout 26 | uses: actions/checkout@v3 27 | 28 | - name: Build 29 | run: xcrun xcodebuild build 30 | -configuration Debug 31 | -project CobraDemo.xcodeproj 32 | -sdk iphoneos 33 | -scheme CobraDemo 34 | -derivedDataPath ddp 35 | CODE_SIGNING_ALLOWED=NO -------------------------------------------------------------------------------- /.github/workflows/java-codestyle.yml: -------------------------------------------------------------------------------- 1 | name: Java CodeStyle 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - '**/*.java' 9 | pull_request: 10 | branches: [ main, 'v[0-9]+.[0-9]+' ] 11 | paths: 12 | - '**/*.java' 13 | 14 | jobs: 15 | check-java-codestyle: 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - uses: actions/checkout@v3 20 | 21 | - name: Set up JDK 11 22 | uses: actions/setup-java@v3 23 | with: 24 | java-version: '11' 25 | distribution: 'temurin' 26 | 27 | - name: Check Java CodeStyle 28 | run: java -Dconfig_loc=res/.lint/java/ -jar res/.lint/java/checkstyle-10.5.0-all.jar -c res/.lint/java/checkstyle.xml binding/android/ demo/android/ 29 | -------------------------------------------------------------------------------- /.github/workflows/link-check.yml: -------------------------------------------------------------------------------- 1 | name: Check Markdown links 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | pull_request: 8 | branches: [ main, 'v[0-9]+.[0-9]+' ] 9 | 10 | jobs: 11 | markdown-link-check: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@master 15 | - uses: gaurav-nelson/github-action-markdown-link-check@1.0.14 16 | with: 17 | use-quiet-mode: 'yes' 18 | use-verbose-mode: 'yes' 19 | -------------------------------------------------------------------------------- /.github/workflows/nodejs-codestyle.yml: -------------------------------------------------------------------------------- 1 | name: Node.js Codestyle 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - '**/nodejs/*.js' 9 | - '**/nodejs/*.ts' 10 | - '.github/workflows/nodejs-codestyle.yml' 11 | pull_request: 12 | branches: [ main, 'v[0-9]+.[0-9]+' ] 13 | paths: 14 | - '**/nodejs/*.js' 15 | - '**/nodejs/*.ts' 16 | - '.github/workflows/nodejs-codestyle.yml' 17 | 18 | jobs: 19 | check-nodejs-codestyle: 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v3 24 | 25 | - name: Set up Node.js LTS 26 | uses: actions/setup-node@v3 27 | with: 28 | node-version: lts/* 29 | 30 | - name: Pre-build dependencies 31 | run: npm install yarn 32 | 33 | - name: Run Binding Linter 34 | run: yarn && yarn lint 35 | working-directory: binding/nodejs 36 | -------------------------------------------------------------------------------- /.github/workflows/nodejs-demos.yml: -------------------------------------------------------------------------------- 1 | name: Node.js Demos 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - 'demo/nodejs/**' 9 | - '!demo/nodejs/README.md' 10 | - 'lib/node/**' 11 | - '.github/workflows/nodejs-demos.yml' 12 | 13 | pull_request: 14 | branches: [ main, 'v[0-9]+.[0-9]+' ] 15 | paths: 16 | - 'demo/nodejs/**' 17 | - '!demo/nodejs/README.md' 18 | - 'lib/node/**' 19 | - '.github/workflows/nodejs-demos.yml' 20 | 21 | defaults: 22 | run: 23 | working-directory: demo/nodejs 24 | 25 | jobs: 26 | build-github-hosted: 27 | runs-on: ${{ matrix.os }} 28 | 29 | strategy: 30 | matrix: 31 | os: [ubuntu-latest, windows-latest, macos-latest] 32 | node-version: [18.x, 20.x, 22.x] 33 | 34 | steps: 35 | - uses: actions/checkout@v3 36 | 37 | - name: Use Node.js ${{ matrix.node-version }} 38 | uses: actions/setup-node@v3 39 | with: 40 | node-version: ${{ matrix.node-version }} 41 | 42 | - name: Install dependencies 43 | run: yarn install 44 | 45 | - name: Test 46 | run: yarn file -a ${{secrets.PV_VALID_ACCESS_KEY}} -i ../../res/audio/sample.wav 47 | 48 | build-self-hosted: 49 | runs-on: ${{ matrix.machine }} 50 | 51 | strategy: 52 | matrix: 53 | machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, pv-windows-arm64] 54 | 55 | steps: 56 | - uses: actions/checkout@v3 57 | 58 | - name: Install dependencies 59 | run: yarn install 60 | 61 | - name: Test 62 | run: yarn file -a ${{secrets.PV_VALID_ACCESS_KEY}} -i ../../res/audio/sample.wav 63 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | name: Node.js 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - 'binding/nodejs/**' 9 | - '!binding/nodejs/README.md' 10 | - 'lib/node/**' 11 | - '.github/workflows/nodejs.yml' 12 | 13 | pull_request: 14 | branches: [ main, 'v[0-9]+.[0-9]+' ] 15 | paths: 16 | - 'binding/nodejs/**' 17 | - '!binding/nodejs/README.md' 18 | - 'lib/node/**' 19 | - '.github/workflows/nodejs.yml' 20 | 21 | defaults: 22 | run: 23 | working-directory: binding/nodejs 24 | 25 | jobs: 26 | build-github-hosted: 27 | runs-on: ${{ matrix.os }} 28 | 29 | strategy: 30 | matrix: 31 | os: [ubuntu-latest, windows-latest, macos-latest] 32 | node-version: [18.x, 20.x, 22.x] 33 | 34 | steps: 35 | - uses: actions/checkout@v3 36 | 37 | - name: Set up Node.js ${{ matrix.node-version }} 38 | uses: actions/setup-node@v3 39 | with: 40 | node-version: ${{ matrix.node-version }} 41 | 42 | - name: Pre-build dependencies 43 | run: npm install yarn 44 | 45 | - name: Install dependencies 46 | run: yarn install 47 | 48 | - name: Test 49 | run: yarn test index.test.ts --access_key=${{secrets.PV_VALID_ACCESS_KEY}} 50 | 51 | build-self-hosted: 52 | runs-on: ${{ matrix.machine }} 53 | 54 | strategy: 55 | matrix: 56 | machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, pv-windows-arm64] 57 | 58 | steps: 59 | - uses: actions/checkout@v3 60 | 61 | - name: Pre-build dependencies 62 | run: npm install --global yarn 63 | 64 | - name: Install dependencies 65 | run: yarn install 66 | 67 | - name: Test 68 | run: yarn test index.test.ts --access_key=${{secrets.PV_VALID_ACCESS_KEY}} 69 | -------------------------------------------------------------------------------- /.github/workflows/python-codestyle.yml: -------------------------------------------------------------------------------- 1 | name: Python Codestyle 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - 'binding/python/*.py' 9 | - 'demo/python/*.py' 10 | - '.github/workflows/python-codestyle.yml' 11 | pull_request: 12 | branches: [ main, 'v[0-9]+.[0-9]+' ] 13 | paths: 14 | - 'binding/python/*.py' 15 | - 'demo/python/*.py' 16 | - '.github/workflows/python-codestyle.yml' 17 | 18 | jobs: 19 | check-python-codestyle: 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v3 24 | 25 | - name: Set up Python 3.10 26 | uses: actions/setup-python@v4 27 | with: 28 | python-version: '3.10' 29 | 30 | - name: Install dependencies 31 | run: pip install flake8 pep8-naming 32 | 33 | - name: Check python codestyle 34 | run: flake8 --ignore=F401,F403,F405 --max-line-length=120 binding/python demo/python -------------------------------------------------------------------------------- /.github/workflows/python-demos.yml: -------------------------------------------------------------------------------- 1 | name: Python Demos 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - '.github/workflows/python-demos.yml' 9 | - 'demo/python/**' 10 | - '!demo/python/README.md' 11 | pull_request: 12 | branches: [ main, 'v[0-9]+.[0-9]+' ] 13 | paths: 14 | - '.github/workflows/python-demos.yml' 15 | - 'demo/python/**' 16 | - '!demo/python/README.md' 17 | 18 | defaults: 19 | run: 20 | working-directory: demo/python 21 | 22 | jobs: 23 | build-github-hosted: 24 | runs-on: ${{ matrix.os }} 25 | 26 | strategy: 27 | matrix: 28 | os: [ubuntu-latest, windows-latest, macos-latest] 29 | python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] 30 | 31 | steps: 32 | - uses: actions/checkout@v3 33 | 34 | - name: Set up Python ${{ matrix.python-version }} 35 | uses: actions/setup-python@v4 36 | with: 37 | python-version: ${{ matrix.python-version }} 38 | 39 | - name: Pre-build dependencies 40 | run: python -m pip install --upgrade pip 41 | 42 | - name: Install dependencies 43 | run: pip install -r requirements.txt 44 | 45 | - name: Test 46 | run: python cobra_demo_file.py --access_key ${{secrets.PV_VALID_ACCESS_KEY}} --input_wav_path ../../res/audio/sample.wav 47 | 48 | build-self-hosted: 49 | runs-on: ${{ matrix.machine }} 50 | 51 | strategy: 52 | matrix: 53 | machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, pv-windows-arm64] 54 | 55 | steps: 56 | - uses: actions/checkout@v3 57 | 58 | - name: Install dependencies 59 | run: pip3 install -r requirements.txt 60 | 61 | - name: Test 62 | run: python3 cobra_demo_file.py --access_key ${{secrets.PV_VALID_ACCESS_KEY}} --input_wav_path ../../res/audio/sample.wav 63 | -------------------------------------------------------------------------------- /.github/workflows/python.yml: -------------------------------------------------------------------------------- 1 | name: Python 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - '.github/workflows/python.yml' 9 | - 'binding/python/**' 10 | - '!binding/python/README.md' 11 | - 'lib/linux/**' 12 | - 'lib/mac/**' 13 | - 'lib/raspberry-pi/**' 14 | - 'lib/windows/**' 15 | - 'res/audio/**' 16 | pull_request: 17 | branches: [ main, 'v[0-9]+.[0-9]+' ] 18 | paths: 19 | - '.github/workflows/python.yml' 20 | - 'binding/python/**' 21 | - '!binding/python/README.md' 22 | - 'lib/linux/**' 23 | - 'lib/mac/**' 24 | - 'lib/raspberry-pi/**' 25 | - 'lib/windows/**' 26 | - 'res/audio/**' 27 | 28 | defaults: 29 | run: 30 | working-directory: binding/python 31 | 32 | jobs: 33 | build: 34 | runs-on: ${{ matrix.os }} 35 | 36 | strategy: 37 | matrix: 38 | os: [ubuntu-latest, windows-latest, macos-latest] 39 | python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] 40 | 41 | steps: 42 | - uses: actions/checkout@v3 43 | 44 | - name: Set up Python ${{ matrix.python-version }} 45 | uses: actions/setup-python@v2 46 | with: 47 | python-version: ${{ matrix.python-version }} 48 | 49 | - name: Pre-build dependencies 50 | run: python -m pip install --upgrade pip 51 | 52 | - name: Install dependencies 53 | run: pip install -r requirements.txt 54 | 55 | - name: Test 56 | run: python test_cobra.py ${{secrets.PV_VALID_ACCESS_KEY}} 57 | 58 | build-self-hosted: 59 | runs-on: ${{ matrix.machine }} 60 | 61 | strategy: 62 | fail-fast: false 63 | matrix: 64 | machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, pv-windows-arm64] 65 | 66 | steps: 67 | - uses: actions/checkout@v3 68 | 69 | - name: Pre-build dependencies 70 | run: python3 -m pip install --upgrade pip 71 | 72 | - name: Install dependencies 73 | run: pip3 install -r requirements.txt 74 | 75 | - name: Test 76 | run: python3 test_cobra.py ${{secrets.PV_VALID_ACCESS_KEY}} 77 | -------------------------------------------------------------------------------- /.github/workflows/rust-codestyle.yml: -------------------------------------------------------------------------------- 1 | name: Rust Codestyle 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - 'binding/rust/**/*.rs' 9 | - 'demo/rust/**/*.rs' 10 | - '.github/workflows/rust-codestyle.yml' 11 | pull_request: 12 | branches: [ main, 'v[0-9]+.[0-9]+' ] 13 | paths: 14 | - 'binding/rust/**/*.rs' 15 | - 'demo/rust/**/*.rs' 16 | - '.github/workflows/rust-codestyle.yml' 17 | 18 | env: 19 | CARGO_TERM_COLOR: always 20 | 21 | defaults: 22 | run: 23 | shell: bash 24 | 25 | jobs: 26 | check-rust-binding-codestyle: 27 | runs-on: ubuntu-latest 28 | 29 | steps: 30 | - uses: actions/checkout@v3 31 | 32 | - name: Rust pre-build 33 | run: bash copy.sh 34 | working-directory: binding/rust 35 | 36 | - name: Rust dependencies 37 | if: matrix.os == 'ubuntu-latest' 38 | run: sudo apt install libasound2-dev -y 39 | 40 | - name: Install stable toolchain 41 | uses: actions-rs/toolchain@v1 42 | with: 43 | profile: minimal 44 | toolchain: stable 45 | override: true 46 | 47 | - name: Run clippy 48 | run: cargo clippy -- -D warnings 49 | working-directory: binding/rust 50 | 51 | check-rust-filedemo-codestyle: 52 | runs-on: ubuntu-latest 53 | 54 | steps: 55 | - uses: actions/checkout@v3 56 | 57 | - name: Rust dependencies 58 | if: matrix.os == 'ubuntu-latest' 59 | run: sudo apt install libasound2-dev -y 60 | 61 | - name: Install stable toolchain 62 | uses: actions-rs/toolchain@v1 63 | with: 64 | profile: minimal 65 | toolchain: stable 66 | override: true 67 | 68 | - name: Run clippy 69 | run: cargo clippy -- -D warnings 70 | working-directory: demo/rust/filedemo 71 | 72 | check-rust-micdemo-codestyle: 73 | runs-on: ubuntu-latest 74 | 75 | steps: 76 | - uses: actions/checkout@v3 77 | 78 | - name: Rust dependencies 79 | if: matrix.os == 'ubuntu-latest' 80 | run: sudo apt install libasound2-dev -y 81 | 82 | - name: Install stable toolchain 83 | uses: actions-rs/toolchain@v1 84 | with: 85 | profile: minimal 86 | toolchain: stable 87 | override: true 88 | 89 | - name: Run clippy 90 | run: cargo clippy -- -D warnings 91 | working-directory: demo/rust/micdemo 92 | -------------------------------------------------------------------------------- /.github/workflows/rust-demos.yml: -------------------------------------------------------------------------------- 1 | name: Rust Demos 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - '.github/workflows/rust-demos.yml' 9 | - 'demo/rust/**' 10 | - '!demo/rust/README.md' 11 | pull_request: 12 | branches: [ main, 'v[0-9]+.[0-9]+' ] 13 | paths: 14 | - '.github/workflows/rust-demos.yml' 15 | - 'demo/rust/**' 16 | - '!demo/rust/README.md' 17 | 18 | defaults: 19 | run: 20 | working-directory: demo/rust 21 | shell: bash 22 | 23 | jobs: 24 | build-github-hosted: 25 | runs-on: ${{ matrix.os }} 26 | 27 | strategy: 28 | matrix: 29 | os: [ubuntu-latest, windows-latest, macos-latest] 30 | 31 | steps: 32 | - uses: actions/checkout@v3 33 | 34 | - name: Rust dependencies 35 | if: matrix.os == 'ubuntu-latest' 36 | run: sudo apt install libasound2-dev -y 37 | 38 | - name: Install stable toolchain 39 | uses: actions-rs/toolchain@v1 40 | with: 41 | profile: minimal 42 | toolchain: stable 43 | override: true 44 | 45 | - name: Rust build micdemo 46 | run: cargo build --verbose 47 | working-directory: demo/rust/micdemo 48 | 49 | - name: Rust build filedemo 50 | run: cargo build --verbose 51 | working-directory: demo/rust/filedemo 52 | 53 | - name: Test 54 | run: cargo run --release -- --access_key ${{secrets.PV_VALID_ACCESS_KEY}} --input_audio_path ../../../res/audio/sample.wav 55 | working-directory: demo/rust/filedemo 56 | 57 | build-self-hosted: 58 | runs-on: ${{ matrix.machine }} 59 | 60 | strategy: 61 | matrix: 62 | machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64] 63 | 64 | steps: 65 | - uses: actions/checkout@v3 66 | 67 | - name: Rust dependencies 68 | if: matrix.os == 'ubuntu-latest' 69 | run: sudo apt install libasound2-dev -y 70 | 71 | - name: Install stable toolchain 72 | uses: actions-rs/toolchain@v1 73 | with: 74 | toolchain: nightly 75 | override: true 76 | 77 | - name: Rust build micdemo 78 | run: cargo build --verbose 79 | working-directory: demo/rust/micdemo 80 | 81 | - name: Rust build filedemo 82 | run: cargo build --verbose 83 | working-directory: demo/rust/filedemo 84 | 85 | - name: Test 86 | run: cargo run --release -- --access_key ${{secrets.PV_VALID_ACCESS_KEY}} --input_audio_path ../../../res/audio/sample.wav 87 | working-directory: demo/rust/filedemo 88 | -------------------------------------------------------------------------------- /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - 'binding/rust/**' 9 | - 'binding/rust/**/*.rs' 10 | - '!binding/rust/README.md' 11 | - 'lib/linux/**' 12 | - 'lib/mac/**' 13 | - 'lib/raspberry-pi/**' 14 | - 'lib/windows/**' 15 | - '.github/workflows/rust.yml' 16 | pull_request: 17 | branches: [ main, 'v[0-9]+.[0-9]+' ] 18 | paths: 19 | - 'binding/rust/**' 20 | - 'binding/rust/**/*.rs' 21 | - '!binding/rust/README.md' 22 | - 'lib/linux/**' 23 | - 'lib/mac/**' 24 | - 'lib/raspberry-pi/**' 25 | - 'lib/windows/**' 26 | - '.github/workflows/rust.yml' 27 | 28 | defaults: 29 | run: 30 | working-directory: binding/rust 31 | 32 | env: 33 | CARGO_TERM_COLOR: always 34 | 35 | jobs: 36 | build: 37 | runs-on: ubuntu-latest 38 | 39 | steps: 40 | - uses: actions/checkout@v3 41 | 42 | - name: Rust dependencies 43 | run: sudo apt install libasound2-dev 44 | 45 | - name: Rust pre-build 46 | run: ./copy.sh 47 | 48 | - name: Rust build 49 | run: cargo build --verbose 50 | 51 | - name: Rust run tests 52 | run: PV_ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}} cargo test --verbose 53 | -------------------------------------------------------------------------------- /.github/workflows/spell-check.yml: -------------------------------------------------------------------------------- 1 | name: SpellCheck 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | pull_request: 8 | branches: [ main, 'v[0-9]+.[0-9]+' ] 9 | 10 | jobs: 11 | markdown: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - uses: actions/setup-node@v3 18 | with: 19 | node-version: 18 20 | 21 | - name: Install CSpell 22 | run: npm install -g cspell 23 | 24 | - name: Run CSpell 25 | run: cspell --config res/.lint/spell-check/.cspell.json "**/*" 26 | -------------------------------------------------------------------------------- /.github/workflows/swift-codestyle.yml: -------------------------------------------------------------------------------- 1 | name: Swift Codestyle 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - '**/*.swift' 9 | - '.github/workflows/swift-codestyle.yml' 10 | pull_request: 11 | branches: [ main, 'v[0-9]+.[0-9]+' ] 12 | paths: 13 | - '**/*.swift' 14 | - '.github/workflows/swift-codestyle.yml' 15 | 16 | jobs: 17 | check-switch-codestyle: 18 | runs-on: ubuntu-latest 19 | 20 | steps: 21 | - uses: actions/checkout@v3 22 | 23 | - name: Check swift codestyle 24 | uses: norio-nomura/action-swiftlint@3.2.1 25 | with: 26 | args: lint --config res/.lint/swift/.swiftlint.yml --strict -------------------------------------------------------------------------------- /.github/workflows/web-codestyle.yml: -------------------------------------------------------------------------------- 1 | name: Web Codestyle 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - '**/web/*.js' 9 | - '**/web/*.ts' 10 | - '.github/workflows/web-codestyle.yml' 11 | pull_request: 12 | branches: [ main, 'v[0-9]+.[0-9]+' ] 13 | paths: 14 | - '**/web/*.js' 15 | - '**/web/*.ts' 16 | - '.github/workflows/web-codestyle.yml' 17 | 18 | jobs: 19 | check-web-codestyle: 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v3 24 | 25 | - name: Set up Node.js lts/* 26 | uses: actions/setup-node@v3 27 | with: 28 | node-version: lts/* 29 | 30 | - name: Pre-build dependencies 31 | run: npm install yarn 32 | 33 | - name: Run Binding Linter 34 | run: yarn && yarn lint 35 | working-directory: binding/web -------------------------------------------------------------------------------- /.github/workflows/web-demos.yml: -------------------------------------------------------------------------------- 1 | name: Web Demos 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - 'demo/web/**' 9 | - '!demo/web/README.md' 10 | - '.github/workflows/web-demos.yml' 11 | pull_request: 12 | branches: [ main, 'v[0-9]+.[0-9]+' ] 13 | paths: 14 | - 'demo/web/**' 15 | - '!demo/web/README.md' 16 | - '.github/workflows/web-demos.yml' 17 | 18 | defaults: 19 | run: 20 | working-directory: demo/web 21 | 22 | jobs: 23 | build: 24 | runs-on: ubuntu-latest 25 | 26 | strategy: 27 | matrix: 28 | node-version: [18.x, 20.x, 22.x] 29 | 30 | steps: 31 | - uses: actions/checkout@v3 32 | 33 | - name: Set up Node.js ${{ matrix.node-version }} 34 | uses: actions/setup-node@v3 35 | with: 36 | node-version: ${{ matrix.node-version }} 37 | 38 | - name: Pre-build dependencies 39 | run: npm install yarn 40 | 41 | - name: Install dependencies 42 | run: yarn install 43 | -------------------------------------------------------------------------------- /.github/workflows/web-perf.yml: -------------------------------------------------------------------------------- 1 | name: Web Performance 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - 'lib/wasm/**' 9 | - '.github/workflows/web-perf.yml' 10 | pull_request: 11 | branches: [ main, 'v[0-9]+.[0-9]+' ] 12 | paths: 13 | - 'lib/wasm/**' 14 | - '.github/workflows/web-perf.yml' 15 | 16 | defaults: 17 | run: 18 | working-directory: binding/web 19 | 20 | jobs: 21 | build: 22 | runs-on: ubuntu-latest 23 | 24 | strategy: 25 | matrix: 26 | node-version: [lts/*] 27 | include: 28 | - node-version: lts/* 29 | procPerformanceThresholdSec: 0.12 30 | 31 | steps: 32 | - uses: actions/checkout@v3 33 | 34 | - name: Set up Node.js ${{ matrix.node-version }} 35 | uses: actions/setup-node@v3 36 | with: 37 | node-version: ${{ matrix.node-version }} 38 | 39 | - name: Pre-build dependencies 40 | run: npm install yarn 41 | 42 | - name: Install dependencies 43 | run: yarn install 44 | 45 | - name: Copy libs 46 | run: yarn copywasm 47 | 48 | - name: Build 49 | run: yarn build 50 | 51 | - name: Prepare Test 52 | run: yarn setup-test 53 | 54 | - name: Test 55 | run: yarn test-perf --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}},NUM_TEST_ITERATIONS=20,PROC_PERFORMANCE_THRESHOLD_SEC=${{matrix.procPerformanceThresholdSec}} 56 | -------------------------------------------------------------------------------- /.github/workflows/web.yml: -------------------------------------------------------------------------------- 1 | name: Web 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | paths: 8 | - 'binding/web/**' 9 | - '!binding/web/README.md' 10 | - 'lib/wasm/**' 11 | - '.github/workflows/web.yml' 12 | pull_request: 13 | branches: [ main, 'v[0-9]+.[0-9]+' ] 14 | paths: 15 | - 'binding/web/**' 16 | - '!binding/web/README.md' 17 | - 'lib/wasm/**' 18 | - '.github/workflows/web.yml' 19 | 20 | defaults: 21 | run: 22 | working-directory: binding/web 23 | 24 | jobs: 25 | build: 26 | runs-on: ubuntu-latest 27 | 28 | strategy: 29 | matrix: 30 | node-version: [16.x, 18.x, 20.x] 31 | 32 | steps: 33 | - uses: actions/checkout@v3 34 | with: 35 | submodules: recursive 36 | 37 | - name: Set up Node.js ${{ matrix.node-version }} 38 | uses: actions/setup-node@v3 39 | with: 40 | node-version: ${{ matrix.node-version }} 41 | 42 | - name: Pre-build dependencies 43 | run: npm install yarn 44 | 45 | - name: Install dependencies 46 | run: yarn install 47 | 48 | - name: Copy libs 49 | run: yarn copywasm 50 | 51 | - name: build 52 | run: yarn build 53 | 54 | - name: Prepare Test 55 | run: yarn setup-test 56 | 57 | - name: Test 58 | run: yarn test --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}} 59 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | demo/c/cobra_demo_file 4 | demo/c/cobra_demo_mic 5 | __pycache__ 6 | .build 7 | Package.resolved 8 | .swiftpm -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "demo/c/dr_libs"] 2 | path = demo/c/dr_libs 3 | url = https://github.com/mackron/dr_libs.git 4 | [submodule "demo/c/pvrecorder"] 5 | path = demo/c/pvrecorder 6 | url = https://github.com/Picovoice/pvrecorder.git 7 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | import PackageDescription 3 | 4 | let package = Package( 5 | name: "Cobra-iOS", 6 | platforms: [ 7 | .iOS(.v13) 8 | ], 9 | products: [ 10 | .library( 11 | name: "Cobra", 12 | targets: ["Cobra"] 13 | ) 14 | ], 15 | targets: [ 16 | .binaryTarget( 17 | name: "PvCobra", 18 | path: "lib/ios/PvCobra.xcframework" 19 | ), 20 | .target( 21 | name: "Cobra", 22 | dependencies: ["PvCobra"], 23 | path: ".", 24 | exclude: [ 25 | "binding/ios/CobraAppTest", 26 | "demo" 27 | ], 28 | sources: [ 29 | "binding/ios/Cobra.swift", 30 | "binding/ios/CobraErrors.swift" 31 | ] 32 | ) 33 | ] 34 | ) 35 | -------------------------------------------------------------------------------- /binding/android/Cobra/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | .settings 17 | .classpath 18 | .project 19 | publish-mavencentral.gradle -------------------------------------------------------------------------------- /binding/android/Cobra/build.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | defaultTargetSdkVersion = 31 3 | } 4 | 5 | buildscript { 6 | repositories { 7 | maven { url "https://plugins.gradle.org/m2/" } 8 | google() 9 | mavenCentral() 10 | } 11 | dependencies { 12 | classpath "com.android.tools.build:gradle:4.2.2" 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | google() 19 | mavenCentral() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | src/main/jniLibs/**/*.so -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | ext { 4 | PUBLISH_GROUP_ID = 'ai.picovoice' 5 | PUBLISH_VERSION = '2.0.1' 6 | PUBLISH_ARTIFACT_ID = 'cobra-android' 7 | } 8 | 9 | android { 10 | compileSdkVersion defaultTargetSdkVersion 11 | 12 | defaultConfig { 13 | minSdkVersion 21 14 | targetSdkVersion defaultTargetSdkVersion 15 | versionCode 1 16 | versionName "1.0" 17 | 18 | consumerProguardFiles "consumer-rules.pro" 19 | } 20 | 21 | buildTypes { 22 | release { 23 | minifyEnabled false 24 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 25 | } 26 | } 27 | compileOptions { 28 | sourceCompatibility JavaVersion.VERSION_1_8 29 | targetCompatibility JavaVersion.VERSION_1_8 30 | } 31 | } 32 | 33 | if (file("${rootDir}/publish-mavencentral.gradle").exists()) { 34 | apply from: "${rootDir}/publish-mavencentral.gradle" 35 | } 36 | 37 | task copyLibs(type: Copy) { 38 | from("${rootDir}/../../../lib/android") 39 | into("${rootDir}/cobra/src/main/jniLibs") 40 | } 41 | 42 | preBuild.dependsOn(copyLibs) 43 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -keep class ai.picovoice.cobra.*Exception { (...); } -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | -keep class ai.picovoice.cobra.*Exception { (...); } -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/CobraNative.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022-2023 Picovoice Inc. 3 | 4 | You may not use this file except in compliance with the license. A copy of the license is 5 | located in the "LICENSE" file accompanying this source. 6 | 7 | Unless required by applicable law or agreed to in writing, software distributed under the 8 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 9 | express or implied. See the License for the specific language governing permissions and 10 | limitations under the License. 11 | */ 12 | 13 | package ai.picovoice.cobra; 14 | 15 | class CobraNative { 16 | 17 | static native String getVersion(); 18 | 19 | static native int getFrameLength(); 20 | 21 | static native int getSampleRate(); 22 | 23 | static native void setSdk(String sdk); 24 | 25 | static native long init(String accessKey) throws CobraException; 26 | 27 | static native void delete(long object); 28 | 29 | static native float process(long object, short[] pcm) throws CobraException; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/exception/CobraActivationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is 4 | located in the "LICENSE" file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the 6 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 7 | express or implied. See the License for the specific language governing permissions and 8 | limitations under the License. 9 | */ 10 | 11 | package ai.picovoice.cobra; 12 | 13 | public class CobraActivationException extends CobraException { 14 | public CobraActivationException(Throwable cause) { 15 | super(cause); 16 | } 17 | 18 | public CobraActivationException(String message) { 19 | super(message); 20 | } 21 | 22 | public CobraActivationException(String message, String[] messageStack) { 23 | super(message, messageStack); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/exception/CobraActivationLimitException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is 4 | located in the "LICENSE" file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the 6 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 7 | express or implied. See the License for the specific language governing permissions and 8 | limitations under the License. 9 | */ 10 | 11 | package ai.picovoice.cobra; 12 | 13 | public class CobraActivationLimitException extends CobraException { 14 | public CobraActivationLimitException(Throwable cause) { 15 | super(cause); 16 | } 17 | 18 | public CobraActivationLimitException(String message) { 19 | super(message); 20 | } 21 | 22 | public CobraActivationLimitException(String message, String[] messageStack) { 23 | super(message, messageStack); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/exception/CobraActivationRefusedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is 4 | located in the "LICENSE" file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the 6 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 7 | express or implied. See the License for the specific language governing permissions and 8 | limitations under the License. 9 | */ 10 | 11 | package ai.picovoice.cobra; 12 | 13 | public class CobraActivationRefusedException extends CobraException { 14 | public CobraActivationRefusedException(Throwable cause) { 15 | super(cause); 16 | } 17 | 18 | public CobraActivationRefusedException(String message) { 19 | super(message); 20 | } 21 | 22 | public CobraActivationRefusedException(String message, String[] messageStack) { 23 | super(message, messageStack); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/exception/CobraActivationThrottledException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is 4 | located in the "LICENSE" file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the 6 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 7 | express or implied. See the License for the specific language governing permissions and 8 | limitations under the License. 9 | */ 10 | 11 | package ai.picovoice.cobra; 12 | 13 | public class CobraActivationThrottledException extends CobraException { 14 | public CobraActivationThrottledException(Throwable cause) { 15 | super(cause); 16 | } 17 | 18 | public CobraActivationThrottledException(String message) { 19 | super(message); 20 | } 21 | 22 | public CobraActivationThrottledException(String message, String[] messageStack) { 23 | super(message, messageStack); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/exception/CobraException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is 4 | located in the "LICENSE" file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the 6 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 7 | express or implied. See the License for the specific language governing permissions and 8 | limitations under the License. 9 | */ 10 | 11 | package ai.picovoice.cobra; 12 | 13 | import android.annotation.SuppressLint; 14 | 15 | public class CobraException extends Exception { 16 | private final String message; 17 | private final String[] messageStack; 18 | 19 | public CobraException(Throwable cause) { 20 | super(cause); 21 | this.message = cause.getMessage(); 22 | this.messageStack = null; 23 | } 24 | 25 | public CobraException(String message) { 26 | super(message); 27 | this.message = message; 28 | this.messageStack = null; 29 | } 30 | 31 | public CobraException(String message, String[] messageStack) { 32 | super(message); 33 | this.message = message; 34 | this.messageStack = messageStack; 35 | } 36 | 37 | public String[] getMessageStack() { 38 | return this.messageStack; 39 | } 40 | 41 | @SuppressLint("DefaultLocale") 42 | @Override 43 | public String getMessage() { 44 | StringBuilder sb = new StringBuilder(message); 45 | if (messageStack != null) { 46 | if (messageStack.length > 0) { 47 | sb.append(":"); 48 | for (int i = 0; i < messageStack.length; i++) { 49 | sb.append(String.format("\n [%d] %s", i, messageStack[i])); 50 | } 51 | } 52 | } 53 | return sb.toString(); 54 | } 55 | } -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/exception/CobraIOException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is 4 | located in the "LICENSE" file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the 6 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 7 | express or implied. See the License for the specific language governing permissions and 8 | limitations under the License. 9 | */ 10 | 11 | package ai.picovoice.cobra; 12 | 13 | public class CobraIOException extends CobraException { 14 | public CobraIOException(Throwable cause) { 15 | super(cause); 16 | } 17 | 18 | public CobraIOException(String message) { 19 | super(message); 20 | } 21 | 22 | public CobraIOException(String message, String[] messageStack) { 23 | super(message, messageStack); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/exception/CobraInvalidArgumentException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is 4 | located in the "LICENSE" file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the 6 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 7 | express or implied. See the License for the specific language governing permissions and 8 | limitations under the License. 9 | */ 10 | 11 | package ai.picovoice.cobra; 12 | 13 | public class CobraInvalidArgumentException extends CobraException { 14 | public CobraInvalidArgumentException(Throwable cause) { 15 | super(cause); 16 | } 17 | 18 | public CobraInvalidArgumentException(String message) { 19 | super(message); 20 | } 21 | 22 | public CobraInvalidArgumentException(String message, String[] messageStack) { 23 | super(message, messageStack); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/exception/CobraInvalidStateException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is 4 | located in the "LICENSE" file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the 6 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 7 | express or implied. See the License for the specific language governing permissions and 8 | limitations under the License. 9 | */ 10 | 11 | package ai.picovoice.cobra; 12 | 13 | public class CobraInvalidStateException extends CobraException { 14 | public CobraInvalidStateException(Throwable cause) { 15 | super(cause); 16 | } 17 | 18 | public CobraInvalidStateException(String message) { 19 | super(message); 20 | } 21 | 22 | public CobraInvalidStateException(String message, String[] messageStack) { 23 | super(message, messageStack); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/exception/CobraKeyException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is 4 | located in the "LICENSE" file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the 6 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 7 | express or implied. See the License for the specific language governing permissions and 8 | limitations under the License. 9 | */ 10 | 11 | package ai.picovoice.cobra; 12 | 13 | public class CobraKeyException extends CobraException { 14 | public CobraKeyException(Throwable cause) { 15 | super(cause); 16 | } 17 | 18 | public CobraKeyException(String message) { 19 | super(message); 20 | } 21 | 22 | public CobraKeyException(String message, String[] messageStack) { 23 | super(message, messageStack); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/exception/CobraMemoryException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is 4 | located in the "LICENSE" file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the 6 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 7 | express or implied. See the License for the specific language governing permissions and 8 | limitations under the License. 9 | */ 10 | 11 | package ai.picovoice.cobra; 12 | 13 | public class CobraMemoryException extends CobraException { 14 | public CobraMemoryException(Throwable cause) { 15 | super(cause); 16 | } 17 | 18 | public CobraMemoryException(String message) { 19 | super(message); 20 | } 21 | 22 | public CobraMemoryException(String message, String[] messageStack) { 23 | super(message, messageStack); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/exception/CobraRuntimeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is 4 | located in the "LICENSE" file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the 6 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 7 | express or implied. See the License for the specific language governing permissions and 8 | limitations under the License. 9 | */ 10 | 11 | package ai.picovoice.cobra; 12 | 13 | public class CobraRuntimeException extends CobraException { 14 | public CobraRuntimeException(Throwable cause) { 15 | super(cause); 16 | } 17 | 18 | public CobraRuntimeException(String message) { 19 | super(message); 20 | } 21 | 22 | public CobraRuntimeException(String message, String[] messageStack) { 23 | super(message, messageStack); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/java/ai/picovoice/cobra/exception/CobraStopIterationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is 4 | located in the "LICENSE" file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the 6 | License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 7 | express or implied. See the License for the specific language governing permissions and 8 | limitations under the License. 9 | */ 10 | 11 | package ai.picovoice.cobra; 12 | 13 | public class CobraStopIterationException extends CobraException { 14 | public CobraStopIterationException(Throwable cause) { 15 | super(cause); 16 | } 17 | 18 | public CobraStopIterationException(String message) { 19 | super(message); 20 | } 21 | 22 | public CobraStopIterationException(String message, String[] messageStack) { 23 | super(message, messageStack); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /binding/android/Cobra/cobra/src/main/jniLibs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/binding/android/Cobra/cobra/src/main/jniLibs/.gitkeep -------------------------------------------------------------------------------- /binding/android/Cobra/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true -------------------------------------------------------------------------------- /binding/android/Cobra/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/binding/android/Cobra/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /binding/android/Cobra/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jun 29 22:27:49 PDT 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /binding/android/Cobra/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /binding/android/Cobra/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "Cobra" 2 | include ':cobra' 3 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/ 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | release 10 | test_resources 11 | 12 | *.jks 13 | !.dummy.jks -------------------------------------------------------------------------------- /binding/android/CobraTestApp/build.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | defaultTargetSdkVersion = 31 3 | } 4 | 5 | buildscript { 6 | repositories { 7 | google() 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:7.2.2' 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | google() 18 | mavenCentral() 19 | } 20 | } 21 | 22 | task clean(type: Delete) { 23 | delete rootProject.buildDir 24 | } 25 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | *.wav -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -keep class com.google.** { *; } 23 | -keep class com.microsoft.** { *; } -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/binding/android/CobraTestApp/cobra-test-app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/java/ai/picovoice/cobra/testapp/TestResult.java: -------------------------------------------------------------------------------- 1 | package ai.picovoice.cobra.testapp; 2 | 3 | public class TestResult { 4 | public String testName; 5 | public boolean success; 6 | public String errorMessage; 7 | } 8 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/res/drawable/button_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/res/drawable/button_disabled.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/res/layout/list_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 23 | 24 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #377DFF 4 | #25187E 5 | #00E5C3 6 | #ff0e0e 7 | 8 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #377dff 4 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Cobra Android Test App 3 | Test 4 | 5 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/cobra-test-app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/copy_test_resources.sh: -------------------------------------------------------------------------------- 1 | if [ ! -d "./cobra-activity-demo-app/src/androidTest/assets/test_resources/audio" ] 2 | then 3 | echo "Creating test audio samples directory..." 4 | mkdir -p ./cobra-test-app/src/androidTest/assets/test_resources/audio 5 | fi 6 | 7 | echo "Copying test audio samples..." 8 | cp ../../../res/audio/sample.wav ./cobra-test-app/src/androidTest/assets/test_resources/audio/sample.wav 9 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/binding/android/CobraTestApp/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /binding/android/CobraTestApp/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jul 19 14:23:40 PDT 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /binding/android/CobraTestApp/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "CobraTestApp" 2 | include ':cobra-test-app' 3 | -------------------------------------------------------------------------------- /binding/android/README.md: -------------------------------------------------------------------------------- 1 | # Cobra Voice Activity Detection Engine 2 | 3 | Made in Vancouver, Canada by [Picovoice](https://picovoice.ai) 4 | 5 | Cobra is a highly accurate and lightweight voice activity detection (VAD) engine. 6 | 7 | ## Compatibility 8 | 9 | - Android SDK 21 or higher 10 | 11 | ## Installation 12 | 13 | Cobra can be found on Maven Central. To include the package in your Android project, ensure you have included `mavenCentral()` 14 | in your top-level `build.gradle` file and then add the following to your app's `build.gradle`: 15 | 16 | ```groovy 17 | dependencies { 18 | // ... 19 | implementation 'ai.picovoice:cobra-android:${version}' 20 | } 21 | ``` 22 | 23 | ## AccessKey 24 | 25 | Cobra requires a valid Picovoice `AccessKey` at initialization. `AccessKey` acts as your credentials when using Cobra SDKs. 26 | You can get your `AccessKey` for free. Make sure to keep your `AccessKey` secret. 27 | Signup or Login to [Picovoice Console](https://console.picovoice.ai/) to get your `AccessKey`. 28 | 29 | ## Permissions 30 | 31 | To enable recording with your Android device's microphone and to communicate to the license server, 32 | you must add the following lines to your `AndroidManifest.xml` file: 33 | ```xml 34 | 35 | 36 | ``` 37 | ## Usage 38 | 39 | Create an instance of the engine 40 | 41 | ```java 42 | import ai.picovoice.cobra.Cobra; 43 | import ai.picovoice.cobra.CobraException; 44 | 45 | String accessKey = // .. AccessKey obtained from Picovoice Console (https://console.picovoice.ai/) 46 | try { 47 | handle = new Cobra(accessKey); 48 | } catch (CobraException e) { 49 | // handle error 50 | } 51 | ``` 52 | 53 | `handle` is an instance of Cobra that detects voice activities. 54 | 55 | ```java 56 | short[] getNextAudioFrame(){ 57 | // .. get audioFrame 58 | return audioFrame; 59 | } 60 | 61 | float threshold = // .. # detection threshold within [0, 1] 62 | 63 | while(true) { 64 | try { 65 | float voiceProbability = handle.process(getNextAudioFrame()); 66 | if(voiceProbability >= threshold) { 67 | // .. detection event callback 68 | } 69 | } catch (CobraException e) { } 70 | } 71 | ``` 72 | 73 | When done, resources have to be released explicitly: 74 | 75 | ```java 76 | handle.delete() 77 | ``` 78 | 79 | ## Demos 80 | 81 | For example usage refer to the [Activity demo](../../demo/android/Activity) 82 | -------------------------------------------------------------------------------- /binding/dotnet/.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .vs 3 | *.user 4 | Cobra/bin 5 | Cobra/obj 6 | Cobra/Properties 7 | CobraTest/bin 8 | CobraTest/obj 9 | TestResults 10 | -------------------------------------------------------------------------------- /binding/dotnet/Cobra.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32210.238 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cobra", "Cobra\Cobra.csproj", "{C7DD584F-DF0B-4FD4-B7BD-F64483C72F79}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CobraTest", "CobraTest\CobraTest.csproj", "{3179843B-9F5B-4BDB-88BA-602C50A5F7DF}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|AnyCPU = Debug|AnyCPU 13 | Release|AnyCPU = Release|AnyCPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {C7DD584F-DF0B-4FD4-B7BD-F64483C72F79}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU 17 | {C7DD584F-DF0B-4FD4-B7BD-F64483C72F79}.Debug|AnyCPU.Build.0 = Debug|Any CPU 18 | {C7DD584F-DF0B-4FD4-B7BD-F64483C72F79}.Release|AnyCPU.ActiveCfg = Release|Any CPU 19 | {C7DD584F-DF0B-4FD4-B7BD-F64483C72F79}.Release|AnyCPU.Build.0 = Release|Any CPU 20 | {3179843B-9F5B-4BDB-88BA-602C50A5F7DF}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU 21 | {3179843B-9F5B-4BDB-88BA-602C50A5F7DF}.Debug|AnyCPU.Build.0 = Debug|Any CPU 22 | {3179843B-9F5B-4BDB-88BA-602C50A5F7DF}.Release|AnyCPU.ActiveCfg = Release|Any CPU 23 | {3179843B-9F5B-4BDB-88BA-602C50A5F7DF}.Release|AnyCPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {F054A3C2-7E52-472A-B552-05093ADCC142} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /binding/dotnet/Cobra/Cobra.netstandard2.0.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | libpv_cobra.dll 5 | PreserveNewest 6 | false 7 | 8 | 9 | libpv_cobra.dylib 10 | PreserveNewest 11 | false 12 | 13 | 14 | content\picovoice\%(RecursiveDir)%(Filename)%(Extension) 15 | lib\%(RecursiveDir)%(Filename)%(Extension) 16 | PreserveNewest 17 | false 18 | 19 | 20 | -------------------------------------------------------------------------------- /binding/dotnet/Cobra/Cobra.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | lib\%(RecursiveDir)%(Filename)%(Extension) 5 | content\picovoice\%(RecursiveDir)%(Filename)%(Extension) 6 | PreserveNewest 7 | false 8 | 9 | 10 | -------------------------------------------------------------------------------- /binding/dotnet/Cobra/Content/pv_circle_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/binding/dotnet/Cobra/Content/pv_circle_512.png -------------------------------------------------------------------------------- /binding/dotnet/CobraTest/CobraTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net6.0;net5.0;netcoreapp3.1;netcoreapp3.0;netcoreapp2.1; 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | res\audio\%(Filename)%(Extension) 21 | PreserveNewest 22 | 23 | 24 | 25 | 26 | 27 | PreserveNewest 28 | libpv_cobra.dll 29 | false 30 | 31 | 32 | PreserveNewest 33 | libpv_cobra.so 34 | false 35 | 36 | 37 | PreserveNewest 38 | libpv_cobra.dylib 39 | false 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /binding/ios/Cobra-iOS.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'Cobra-iOS' 3 | s.module_name = 'Cobra' 4 | s.version = '2.0.2' 5 | s.license = {:type => 'Apache 2.0'} 6 | s.summary = 'iOS binding for Picovoice\'s Cobra voice activity detection (VAD) engine.' 7 | s.description = 8 | <<-DESC 9 | Made in Vancouver, Canada by [Picovoice](https://picovoice.ai) 10 | 11 | Cobra is a highly-accurate and lightweight voice activity detection (VAD) engine. 12 | DESC 13 | s.homepage = 'https://github.com/Picovoice/cobra/tree/master/binding/ios' 14 | s.author = { 'Picovoice' => 'hello@picovoice.ai' } 15 | s.source = { :git => "https://github.com/Picovoice/cobra.git", :tag => s.version.to_s } 16 | s.ios.deployment_target = '13.0' 17 | s.swift_version = '5.0' 18 | s.vendored_frameworks = 'lib/ios/PvCobra.xcframework' 19 | s.source_files = 'binding/ios/*.{swift}' 20 | s.exclude_files = 'binding/ios/CobraAppTest/**' 21 | end 22 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/.gitignore: -------------------------------------------------------------------------------- 1 | # Exclude the build directory 2 | build/* 3 | 4 | # Exclude temp nibs and swap files 5 | *~.nib 6 | *.swp 7 | 8 | # Exclude OS X folder attributes 9 | .DS_Store 10 | 11 | # Exclude user-specific XCode 3 and 4 files 12 | *.mode1 13 | *.mode1v3 14 | *.mode2v3 15 | *.perspective 16 | *.perspectivev3 17 | *.pbxuser 18 | xcuserdata 19 | Pods 20 | ddp 21 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/CobraAppTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/CobraAppTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/CobraAppTest/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2022 Picovoice Inc. 3 | // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 4 | // file accompanying this source. 5 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 6 | // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 7 | // specific language governing permissions and limitations under the License. 8 | // 9 | 10 | import UIKit 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | var window: UIWindow? 15 | 16 | func application( 17 | _ application: UIApplication, 18 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 19 | ) -> Bool { 20 | return true 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/CobraAppTest/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/CobraAppTest/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/CobraAppTest/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/CobraAppTest/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/CobraAppTest/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/CobraAppTest/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | PorcupineDemoApp 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(MARKETING_VERSION) 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/CobraAppTest/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2022-2023 Picovoice Inc. 3 | // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 4 | // file accompanying this source. 5 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 6 | // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 7 | // specific language governing permissions and limitations under the License. 8 | // 9 | 10 | import UIKit 11 | 12 | class ViewController: UIViewController { } 13 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/CobraAppTestUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /binding/ios/CobraAppTest/PerformanceTest/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /binding/ios/CobraErrors.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021-2024 Picovoice Inc. 3 | // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 4 | // file accompanying this source. 5 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 6 | // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 7 | // specific language governing permissions and limitations under the License. 8 | // 9 | 10 | import Foundation 11 | 12 | public class CobraError: LocalizedError { 13 | private let message: String 14 | private let messageStack: [String] 15 | 16 | public init (_ message: String, _ messageStack: [String] = []) { 17 | self.message = message 18 | self.messageStack = messageStack 19 | } 20 | 21 | public var errorDescription: String? { 22 | var messageString = message 23 | if messageStack.count > 0 { 24 | messageString += ":" 25 | for i in 0..=18.0.0" 53 | }, 54 | "cpu": [ 55 | "!ia32", 56 | "!mips", 57 | "!ppc", 58 | "!ppc64" 59 | ], 60 | "dependencies": {} 61 | } 62 | -------------------------------------------------------------------------------- /binding/nodejs/src/index.ts: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2024 Picovoice Inc. 3 | // 4 | // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | // file accompanying this source. 6 | // 7 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | // specific language governing permissions and limitations under the License. 10 | // 11 | 'use strict'; 12 | 13 | import Cobra from './cobra'; 14 | 15 | import { getInt16Frames, checkWaveFile } from './wave_util'; 16 | 17 | import { CobraOptions } from './types'; 18 | 19 | import * as CobraErrors from './errors'; 20 | 21 | export { 22 | Cobra, 23 | CobraErrors, 24 | CobraOptions, 25 | checkWaveFile, 26 | getInt16Frames, 27 | }; 28 | -------------------------------------------------------------------------------- /binding/nodejs/src/pv_status_t.ts: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2024 Picovoice Inc. 3 | // 4 | // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | // file accompanying this source. 6 | // 7 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | // specific language governing permissions and limitations under the License. 10 | // 11 | 'use strict'; 12 | 13 | enum PvStatus { 14 | SUCCESS = 0, 15 | OUT_OF_MEMORY, 16 | IO_ERROR, 17 | INVALID_ARGUMENT, 18 | STOP_ITERATION, 19 | KEY_ERROR, 20 | INVALID_STATE, 21 | RUNTIME_ERROR, 22 | ACTIVATION_ERROR, 23 | ACTIVATION_LIMIT_REACHED, 24 | ACTIVATION_THROTTLED, 25 | ACTIVATION_REFUSED, 26 | } 27 | 28 | export default PvStatus; 29 | -------------------------------------------------------------------------------- /binding/nodejs/src/types.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Picovoice Inc. 3 | You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 4 | file accompanying this source. 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 6 | an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 7 | specific language governing permissions and limitations under the License. 8 | */ 9 | 10 | export type CobraOptions = { 11 | libraryPath?: string; 12 | }; 13 | -------------------------------------------------------------------------------- /binding/nodejs/src/wave_util.ts: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2024 Picovoice Inc. 3 | // 4 | // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | // file accompanying this source. 6 | // 7 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | // specific language governing permissions and limitations under the License. 10 | // 11 | 'use strict'; 12 | 13 | function chunkArray(array: Int16Array, size: number): Int16Array[] { 14 | return Array.from({ length: Math.ceil(array.length / size) }, (v, index) => 15 | array.slice(index * size, index * size + size) 16 | ); 17 | } 18 | 19 | export function checkWaveFile( 20 | waveFile: any, 21 | engineSampleRate: number 22 | ): boolean { 23 | let valid = true; 24 | 25 | if (waveFile.bitDepth !== '16') { 26 | // eslint-disable-next-line no-console 27 | console.error('Audio bit depth must be 16-bit'); 28 | valid = false; 29 | } 30 | 31 | if (waveFile.fmt.numChannels !== 1) { 32 | // eslint-disable-next-line no-console 33 | console.error('Audio must be single channel'); 34 | valid = false; 35 | } 36 | 37 | if (waveFile.fmt.sampleRate !== engineSampleRate) { 38 | // eslint-disable-next-line no-console 39 | console.error( 40 | `Audio sample rate ${waveFile.sampleRate} does not match Picovoice sample rate ${engineSampleRate}` 41 | ); 42 | valid = false; 43 | } 44 | 45 | return valid; 46 | } 47 | 48 | export function getInt16Frames( 49 | waveFile: any, 50 | frameLength: number 51 | ): Int16Array[] { 52 | const samples = waveFile.getSamples(false, Int16Array); 53 | 54 | const frames = chunkArray(samples, frameLength); 55 | 56 | // throw out remainder / partial frame 57 | if (frames[frames.length - 1].length !== frameLength) { 58 | frames.pop(); 59 | } 60 | 61 | return frames; 62 | } 63 | -------------------------------------------------------------------------------- /binding/nodejs/test/test_utils.ts: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2024 Picovoice Inc. 3 | // 4 | // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | // file accompanying this source. 6 | // 7 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | // specific language governing permissions and limitations under the License. 10 | // 11 | import * as path from 'path'; 12 | 13 | const ROOT_DIR = path.join(__dirname, '../../..'); 14 | 15 | export function getAudioFile(audioFile: string): string { 16 | return path.join(ROOT_DIR, 'res/audio', audioFile); 17 | } 18 | -------------------------------------------------------------------------------- /binding/nodejs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["esnext"], 4 | "target": "esnext", 5 | "module": "commonjs", 6 | "moduleResolution": "node", 7 | "outDir": "./dist", 8 | "allowJs": false, 9 | "allowSyntheticDefaultImports": true, 10 | "downlevelIteration": true, 11 | "isolatedModules": false, 12 | "noEmit": false, 13 | "removeComments": false, 14 | "resolveJsonModule": true, 15 | "sourceMap": true, 16 | "strict": true, 17 | "noImplicitAny": true 18 | }, 19 | "exclude": ["node_modules", "dist", "test"] 20 | } 21 | -------------------------------------------------------------------------------- /binding/python/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | dist 3 | MANIFEST.in 4 | pvcobra 5 | pvcobra.egg-info 6 | .idea -------------------------------------------------------------------------------- /binding/python/README.md: -------------------------------------------------------------------------------- 1 | # Cobra Voice Activity Detection Engine 2 | 3 | Made in Vancouver, Canada by [Picovoice](https://picovoice.ai) 4 | 5 | Cobra is a highly accurate and lightweight voice activity detection (VAD) engine. 6 | 7 | ## Compatibility 8 | 9 | - Python 3.9+ 10 | - Runs on Linux (x86_64), macOS (x86_64), Windows (x86_64, arm64), and Raspberry Pi (3, 4, 5). 11 | 12 | ## Installation 13 | 14 | ```console 15 | pip3 install pvcobra 16 | ``` 17 | 18 | ## AccessKey 19 | 20 | Cobra requires a valid Picovoice `AccessKey` at initialization. `AccessKey` acts as your credentials when using Cobra SDKs. 21 | You can get your `AccessKey` for free. Make sure to keep your `AccessKey` secret. 22 | Signup or Login to [Picovoice Console](https://console.picovoice.ai/) to get your `AccessKey`. 23 | 24 | ## Usage 25 | 26 | Create an instance of the engine 27 | 28 | ```python 29 | import pvcobra 30 | 31 | handle = pvcobra.create(access_key=${AccessKey}) 32 | ``` 33 | Replace `${AccessKey}` with your AccessKey obtained from [Picovoice Console](https://console.picovoice.ai/). `handle` is 34 | an instance of Cobra. 35 | 36 | When initialized, the valid sample rate is given by `handle.sample_rate`. Expected frame length (number of audio samples 37 | in an input array) is `handle.frame_length`. The engine accepts 16-bit linearly-encoded PCM and operates on 38 | single-channel audio. 39 | 40 | ```python 41 | def get_next_audio_frame(): 42 | pass 43 | 44 | while True: 45 | voice_probability = handle.process(get_next_audio_frame()) 46 | ``` 47 | 48 | When done, resources have to be released explicitly: 49 | 50 | ```python 51 | handle.delete() 52 | ``` 53 | 54 | ## Demos 55 | 56 | [pvcobrademo](https://pypi.org/project/pvcobrademo/) provides command-line utilities for processing real-time 57 | audio (i.e. microphone) and files using Cobra. 58 | -------------------------------------------------------------------------------- /binding/python/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021-2023 Picovoice Inc. 3 | # 4 | # You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | # file accompanying this source. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | # specific language governing permissions and limitations under the License. 10 | # 11 | 12 | from ._factory import * 13 | from ._cobra import * 14 | from ._util import * 15 | -------------------------------------------------------------------------------- /binding/python/_factory.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021-2023 Picovoice Inc. 3 | # 4 | # You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | # file accompanying this source. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | # specific language governing permissions and limitations under the License. 10 | # 11 | 12 | from typing import Optional 13 | 14 | from ._cobra import * 15 | from ._util import * 16 | 17 | 18 | def create( 19 | access_key: str, 20 | library_path: Optional[str] = None) -> Cobra: 21 | """ 22 | Factory method for Cobra voice activity detection (VAD) engine. 23 | 24 | :param access_key: AccessKey provided by Picovoice Console (https://console.picovoice.ai/) 25 | :param library_path: Absolute path to Cobra's dynamic library. If not set it will be set to the default 26 | :return: An instance of Cobra voice activity detection engine. 27 | """ 28 | 29 | if library_path is None: 30 | library_path = pv_library_path('') 31 | 32 | return Cobra(access_key=access_key, library_path=library_path) 33 | 34 | 35 | __all__ = [ 36 | 'create', 37 | ] 38 | -------------------------------------------------------------------------------- /binding/python/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/binding/python/requirements.txt -------------------------------------------------------------------------------- /binding/python/test_cobra_perf.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2022-2023 Picovoice Inc. 3 | # 4 | # You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | # file accompanying this source. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | # specific language governing permissions and limitations under the License. 10 | # 11 | 12 | import sys 13 | import time 14 | import unittest 15 | 16 | from _cobra import Cobra 17 | from _util import * 18 | from test_util import * 19 | 20 | 21 | class CobraPerformanceTestCase(unittest.TestCase): 22 | ACCESS_KEY = sys.argv[1] 23 | NUM_TEST_ITERATIONS = int(sys.argv[2]) 24 | PERFORMANCE_THRESHOLD_SEC = float(sys.argv[3]) 25 | 26 | def test_performance(self): 27 | cobra = Cobra(access_key=sys.argv[1], library_path=pv_library_path('../..')) 28 | audio = read_wav_file( 29 | os.path.join(os.path.dirname(__file__), '../../res/audio/sample.wav'), 30 | cobra.sample_rate) 31 | 32 | num_frames = len(audio) // cobra.frame_length 33 | perf_results = [] 34 | for i in range(self.NUM_TEST_ITERATIONS): 35 | proc_time = 0 36 | 37 | for j in range(num_frames): 38 | frame = audio[j * cobra.frame_length:(j + 1) * cobra.frame_length] 39 | start = time.time() 40 | cobra.process(frame) 41 | proc_time += time.time() - start 42 | 43 | if i > 0: 44 | perf_results.append(proc_time) 45 | 46 | cobra.delete() 47 | 48 | avg_perf = sum(perf_results) / self.NUM_TEST_ITERATIONS 49 | print("Average performance: %s" % avg_perf) 50 | self.assertLess(avg_perf, self.PERFORMANCE_THRESHOLD_SEC) 51 | 52 | 53 | if __name__ == '__main__': 54 | if len(sys.argv) != 4: 55 | print("usage: test_cobra_perf.py ${ACCESS_KEY} ${NUM_TEST_INTERVALS} ${PERFORMANCE_THRESHOLD_SEC}") 56 | exit(1) 57 | 58 | unittest.main(argv=sys.argv[:1]) 59 | -------------------------------------------------------------------------------- /binding/python/test_util.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2022 Picovoice Inc. 3 | # 4 | # You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | # file accompanying this source. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | # specific language governing permissions and limitations under the License. 10 | # 11 | 12 | import struct 13 | import wave 14 | 15 | 16 | def read_wav_file(file_name, sample_rate): 17 | wav_file = wave.open(file_name, mode="rb") 18 | channels = wav_file.getnchannels() 19 | num_frames = wav_file.getnframes() 20 | 21 | if wav_file.getframerate() != sample_rate: 22 | raise ValueError( 23 | "Audio file should have a sample rate of %d, got %d" % (sample_rate, wav_file.getframerate())) 24 | 25 | samples = wav_file.readframes(num_frames) 26 | wav_file.close() 27 | 28 | frames = struct.unpack('h' * num_frames * channels, samples) 29 | 30 | if channels == 2: 31 | print("Picovoice processes single-channel audio but stereo file is provided. Processing left channel only.") 32 | 33 | return frames[::channels] 34 | -------------------------------------------------------------------------------- /binding/rust/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | data/resources/* 3 | data/lib/* -------------------------------------------------------------------------------- /binding/rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pv_cobra" 3 | version = "2.0.3" 4 | edition = "2018" 5 | description = "The Rust bindings for Picovoice's Cobra library" 6 | license = "Apache-2.0" 7 | homepage = "https://picovoice.ai/platform/cobra/" 8 | repository = "https://github.com/Picovoice/cobra" 9 | keywords = [ 10 | "voice-activity", 11 | "voice-detection", 12 | "VAD", 13 | ] 14 | publish = true 15 | 16 | include = [ 17 | ".gitignore", 18 | "build.rs", 19 | "Cargo.toml", 20 | "data/", 21 | "README.md", 22 | "src/", 23 | ] 24 | 25 | [lib] 26 | name = "cobra" 27 | path = "src/lib.rs" 28 | crate_type = ["lib"] 29 | 30 | [dependencies] 31 | libc = "0.2" 32 | libloading = "0.7" 33 | log = "0.4" 34 | 35 | [dev-dependencies] 36 | rodio = "0.16" 37 | itertools = "0.10" 38 | -------------------------------------------------------------------------------- /binding/rust/README.md: -------------------------------------------------------------------------------- 1 | # Cobra Voice Activity Detection Engine 2 | 3 | > Rust SDKs will no longer be maintained after **July 15, 2025**. If you plan to use the Cobra Voice Activity Detection Rust SDK for commercial purposes, please [contact us](https://picovoice.ai/contact/). 4 | 5 | Made in Vancouver, Canada by [Picovoice](https://picovoice.ai) 6 | 7 | Cobra is a highly accurate and lightweight voice activity detection (VAD) engine. 8 | 9 | ## Compatibility 10 | 11 | - Rust 1.54+ 12 | - Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), and Raspberry Pi (3, 4, 5) 13 | 14 | ## Installation 15 | First you will need [Rust and Cargo](https://rustup.rs/) installed on your system. 16 | 17 | To add the cobra library into your app, add `pv_cobra` to your apps `Cargo.toml` manifest: 18 | ```toml 19 | [dependencies] 20 | pv_cobra = "*" 21 | ``` 22 | 23 | ## AccessKey 24 | 25 | Cobra requires a valid Picovoice `AccessKey` at initialization. `AccessKey` acts as your credentials when using Cobra SDKs. 26 | You can get your `AccessKey` for free. Make sure to keep your `AccessKey` secret. 27 | Signup or Login to [Picovoice Console](https://console.picovoice.ai/) to get your `AccessKey`. 28 | 29 | ## Usage 30 | 31 | Create an instance of the engine: 32 | 33 | ```rust 34 | use cobra::Cobra; 35 | 36 | let access_key = "..."; // AccessKey provided by Picovoice Console (https://console.picovoice.ai/) 37 | let cobra = Cobra::new(access_key); 38 | ``` 39 | where `access_key` is an AccessKey which should be obtained from [Picovoice Console](https://console.picovoice.ai/). `cobra` is an instance of Cobra that detects voice activities. 40 | 41 | ```rust 42 | fn next_audio_frame() -> Vec { 43 | // get audio frame 44 | } 45 | 46 | let threshold = ... // Detection threshold within [0, 1] 47 | 48 | loop { 49 | if let Ok(voice_probability) = cobra.process(&next_audio_frame()) { 50 | if voice_probability >= threshold { 51 | // Detection event! 52 | } 53 | } 54 | } 55 | ``` 56 | 57 | Use `new_with_library` to override the default library path: 58 | 59 | ```rust 60 | use cobra::Cobra; 61 | 62 | let access_key = "..."; // AccessKey provided by Picovoice Console (https://console.picovoice.ai/) 63 | let cobra = Cobra::new_with_library(access_key, "/path/to/library/file"); 64 | ``` 65 | 66 | ## Demos 67 | 68 | Check out the Cobra Rust demos [here](../../demo/rust) 69 | -------------------------------------------------------------------------------- /binding/rust/build.rs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021-2023 Picovoice Inc. 3 | 4 | You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | file accompanying this source. 6 | 7 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | use std::env; 13 | use std::fs; 14 | use std::path::{Path, PathBuf}; 15 | 16 | fn copy_dir, V: AsRef>(from: U, to: V) -> Result<(), std::io::Error> { 17 | let mut stack = Vec::new(); 18 | stack.push(PathBuf::from(from.as_ref())); 19 | 20 | let output_root = PathBuf::from(to.as_ref()); 21 | let input_root = PathBuf::from(from.as_ref()).components().count(); 22 | 23 | while let Some(working_path) = stack.pop() { 24 | let src: PathBuf = working_path.components().skip(input_root).collect(); 25 | 26 | let dest = if src.components().count() == 0 { 27 | output_root.clone() 28 | } else { 29 | output_root.join(&src) 30 | }; 31 | 32 | if fs::metadata(&dest).is_err() { 33 | fs::create_dir_all(&dest)?; 34 | } 35 | 36 | for entry in fs::read_dir(working_path)? { 37 | let entry = entry?; 38 | let path = entry.path(); 39 | if path.is_dir() { 40 | stack.push(path); 41 | } else if let Some(filename) = path.file_name() { 42 | let dest_path = dest.join(filename); 43 | fs::copy(&path, &dest_path)?; 44 | } 45 | } 46 | } 47 | 48 | Ok(()) 49 | } 50 | 51 | fn main() { 52 | let base_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("data/"); 53 | let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); 54 | 55 | let lib_base_dir = base_dir.join("lib/"); 56 | let lib_out_dir = out_dir.join("lib/"); 57 | copy_dir(lib_base_dir, lib_out_dir).unwrap(); 58 | } 59 | -------------------------------------------------------------------------------- /binding/rust/copy.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | echo "Removing old data ..." 4 | rm -rf ./data 5 | 6 | 7 | echo "Preparing dir ..." 8 | mkdir -p ./data/lib/ 9 | 10 | 11 | for platform in linux mac raspberry-pi windows 12 | do 13 | echo "Copying Library Files for $platform ..." 14 | cp -r ../../lib/$platform ./data/lib/ 15 | done 16 | 17 | echo "Copy complete!" 18 | -------------------------------------------------------------------------------- /binding/rust/src/lib.rs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Picovoice Inc. 3 | 4 | You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | file accompanying this source. 6 | 7 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | mod cobra; 13 | mod util; 14 | 15 | pub use crate::cobra::*; 16 | -------------------------------------------------------------------------------- /binding/rust/test.sh: -------------------------------------------------------------------------------- 1 | ./copy.sh && \ 2 | PV_ACCESS_KEY="$1" cargo test && \ 3 | PV_ACCESS_KEY="$1" cargo test --release 4 | -------------------------------------------------------------------------------- /binding/web/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"], 3 | "plugins": ["@babel/plugin-transform-runtime"] 4 | } 5 | -------------------------------------------------------------------------------- /binding/web/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | lib/pv_cobra*.wasm 4 | cypress/fixtures/audio_samples/* 5 | -------------------------------------------------------------------------------- /binding/web/.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | .DS_Store 4 | test 5 | lib 6 | -------------------------------------------------------------------------------- /binding/web/.prettierignore: -------------------------------------------------------------------------------- 1 | .eslintrc.js 2 | src/wasm/pv_cobra* 3 | -------------------------------------------------------------------------------- /binding/web/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "trailingComma": "es5", 4 | "singleQuote": true, 5 | "printWidth": 80, 6 | "tabWidth": 2, 7 | "arrowParens": "avoid" 8 | } 9 | -------------------------------------------------------------------------------- /binding/web/cypress.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "cypress"; 2 | 3 | export default defineConfig({ 4 | env: { 5 | "NUM_TEST_ITERATIONS": 15, 6 | "PROC_PERFORMANCE_THRESHOLD_SEC": 0.12 7 | }, 8 | e2e: { 9 | defaultCommandTimeout: 30000, 10 | supportFile: "cypress/support/index.ts", 11 | specPattern: "test/*.test.{js,jsx,ts,tsx}", 12 | video: false, 13 | screenshotOnRunFailure: false 14 | }, 15 | }); 16 | -------------------------------------------------------------------------------- /binding/web/cypress/fixtures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/binding/web/cypress/fixtures/.gitkeep -------------------------------------------------------------------------------- /binding/web/cypress/support/commands.ts: -------------------------------------------------------------------------------- 1 | 2 | const WAV_HEADER_SIZE = 44; 3 | 4 | Cypress.Commands.add("getFramesFromFile", (path: string) => { 5 | cy.fixture(path, 'base64').then(Cypress.Blob.base64StringToBlob).then(async blob => { 6 | const data = new Int16Array(await blob.arrayBuffer()); 7 | return data.slice(WAV_HEADER_SIZE / Int16Array.BYTES_PER_ELEMENT); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /binding/web/cypress/support/component-index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Components App 8 | 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /binding/web/cypress/support/index.ts: -------------------------------------------------------------------------------- 1 | import "./commands"; 2 | 3 | declare global { 4 | namespace Cypress { 5 | interface Chainable { 6 | getFramesFromFile(path: string): Chainable; 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /binding/web/cypress/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "types": ["cypress"] 5 | }, 6 | "include": [ 7 | "../test/**/*.ts", 8 | "./**/*.ts" 9 | ], 10 | "exclude": [] 11 | } 12 | -------------------------------------------------------------------------------- /binding/web/lib/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/binding/web/lib/.gitkeep -------------------------------------------------------------------------------- /binding/web/module.d.ts: -------------------------------------------------------------------------------- 1 | declare module "*.wasm" { 2 | const content: string; 3 | export default content; 4 | } 5 | 6 | declare module 'web-worker:*' { 7 | const WorkerFactory: new () => Worker; 8 | export default WorkerFactory; 9 | } 10 | -------------------------------------------------------------------------------- /binding/web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@picovoice/cobra-web", 3 | "description": "Cobra VAD engine for web browsers (via WebAssembly)", 4 | "author": "Picovoice Inc", 5 | "license": "Apache-2.0", 6 | "version": "2.0.3", 7 | "keywords": [ 8 | "cobra", 9 | "web", 10 | "voice", 11 | "speech", 12 | "recognition", 13 | "voice activity detection", 14 | "ai", 15 | "VAD", 16 | "offline", 17 | "hooks" 18 | ], 19 | "entry": "src/index.ts", 20 | "module": "dist/esm/index.js", 21 | "iife": "dist/iife/index.js", 22 | "types": "dist/types/index.d.ts", 23 | "scripts": { 24 | "build:all": "rollup --config", 25 | "build:types": "tsc --declaration --declarationMap --emitDeclarationOnly --outDir ./dist/types", 26 | "build": "npm-run-all --parallel build:**", 27 | "lint": "eslint . --ext .js,.ts", 28 | "prepack": "npm-run-all build", 29 | "start": "cross-env TARGET='debug' rollup --config --watch", 30 | "watch": "rollup --config --watch", 31 | "format": "prettier --write \"**/*.{js,ts,json}\"", 32 | "copywasm": "node scripts/copy_wasm.js", 33 | "setup-test": "node scripts/setup_test.js", 34 | "test": "cypress run --spec test/cobra.test.ts", 35 | "test-perf": "cypress run --spec test/cobra_perf.test.ts" 36 | }, 37 | "dependencies": { 38 | "@picovoice/web-utils": "=1.3.1" 39 | }, 40 | "devDependencies": { 41 | "@babel/core": "^7.21.3", 42 | "@babel/plugin-transform-runtime": "^7.21.0", 43 | "@babel/preset-env": "^7.20.2", 44 | "@babel/runtime": "^7.21.0", 45 | "@rollup/plugin-babel": "^6.0.3", 46 | "@rollup/plugin-commonjs": "^24.0.1", 47 | "@rollup/plugin-node-resolve": "^15.0.1", 48 | "@rollup/plugin-terser": "^0.4.0", 49 | "@rollup/pluginutils": "^5.0.2", 50 | "@typescript-eslint/eslint-plugin": "^5.51.0", 51 | "@typescript-eslint/parser": "^5.51.0", 52 | "async-mutex": "^0.4.0", 53 | "cross-env": "^7.0.3", 54 | "cypress": "~12.8.1", 55 | "eslint": "^8.22.0", 56 | "eslint-plugin-cypress": "^2.12.1", 57 | "npm-run-all": "^4.1.5", 58 | "prettier": "^2.8.3", 59 | "rollup": "^2.79.1", 60 | "rollup-plugin-typescript2": "^0.34.1", 61 | "rollup-plugin-web-worker-loader": "^1.6.1", 62 | "tslib": "^2.5.0", 63 | "typescript": "^4.9.5", 64 | "wasm-feature-detect": "^1.5.0" 65 | }, 66 | "engines": { 67 | "node": ">=16" 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /binding/web/rollup.config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const path = require('path'); 3 | const { nodeResolve } = require('@rollup/plugin-node-resolve'); 4 | const commonjs = require('@rollup/plugin-commonjs'); 5 | const typescript = require('rollup-plugin-typescript2'); 6 | const workerLoader = require('rollup-plugin-web-worker-loader'); 7 | const pkg = require('./package.json'); 8 | const { babel } = require('@rollup/plugin-babel'); 9 | const terser = require('@rollup/plugin-terser'); 10 | const { DEFAULT_EXTENSIONS } = require('@babel/core'); 11 | const { base64 } = require('@picovoice/web-utils/plugins'); 12 | 13 | const extensions = [...DEFAULT_EXTENSIONS, '.ts']; 14 | 15 | console.log(process.env.TARGET); 16 | console.log(extensions); 17 | 18 | function capitalizeFirstLetter(string) { 19 | return string.charAt(0).toUpperCase() + string.slice(1); 20 | } 21 | 22 | const iifeBundleName = pkg.name 23 | .split('@picovoice/')[1] 24 | .split('-') 25 | .map(word => capitalizeFirstLetter(word)) 26 | .join(''); 27 | console.log(iifeBundleName); 28 | 29 | export default { 30 | input: [path.resolve(__dirname, pkg.entry)], 31 | output: [ 32 | { 33 | file: path.resolve(__dirname, pkg.module), 34 | format: 'esm', 35 | sourcemap: false, 36 | }, 37 | { 38 | file: path.resolve(__dirname, 'dist', 'esm', 'index.min.js'), 39 | format: 'esm', 40 | sourcemap: false, 41 | plugins: [terser()], 42 | }, 43 | { 44 | file: path.resolve(__dirname, pkg.iife), 45 | format: 'iife', 46 | name: iifeBundleName, 47 | sourcemap: false, 48 | }, 49 | { 50 | file: path.resolve(__dirname, 'dist', 'iife', 'index.min.js'), 51 | format: 'iife', 52 | name: iifeBundleName, 53 | sourcemap: false, 54 | plugins: [terser()], 55 | }, 56 | ], 57 | plugins: [ 58 | nodeResolve({ extensions }), 59 | commonjs(), 60 | workerLoader({ targetPlatform: 'browser', sourcemap: false }), 61 | typescript({ 62 | typescript: require('typescript'), 63 | cacheRoot: path.resolve(__dirname, '.rts2_cache'), 64 | clean: true, 65 | }), 66 | babel({ 67 | extensions: extensions, 68 | babelHelpers: 'runtime', 69 | exclude: '**/node_modules/**', 70 | }), 71 | base64({ 72 | include: ['./lib/**/*.wasm'] 73 | }) 74 | ], 75 | }; 76 | -------------------------------------------------------------------------------- /binding/web/scripts/copy_wasm.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const { join } = require('path'); 3 | 4 | const wasmFiles = ['pv_cobra.wasm', 'pv_cobra_simd.wasm']; 5 | 6 | console.log('Copying the WASM model...'); 7 | 8 | const sourceDirectory = join( 9 | __dirname, 10 | '..', 11 | '..', 12 | '..', 13 | 'lib', 14 | 'wasm', 15 | ); 16 | 17 | const outputDirectory = join(__dirname, '..', 'lib'); 18 | 19 | try { 20 | fs.mkdirSync(outputDirectory, { recursive: true }); 21 | wasmFiles.forEach(file => { 22 | fs.copyFileSync(join(sourceDirectory, file), join(outputDirectory, file)); 23 | }); 24 | } catch (error) { 25 | console.error(error); 26 | } 27 | 28 | console.log('... Done!'); 29 | -------------------------------------------------------------------------------- /binding/web/scripts/setup_test.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const { join } = require('path'); 3 | 4 | console.log('Copying the cobra resources...'); 5 | 6 | const fixturesDirectory = join(__dirname, '..', 'cypress', 'fixtures'); 7 | 8 | const sourceDirectory = join( 9 | __dirname, 10 | "..", 11 | "..", 12 | "..", 13 | "res", 14 | ); 15 | 16 | try { 17 | fs.mkdirSync(join(fixturesDirectory, 'audio_samples'), { recursive: true }); 18 | fs.readdirSync(join(sourceDirectory, 'audio')).forEach(file => { 19 | fs.copyFileSync(join(sourceDirectory, 'audio', file), join(fixturesDirectory, 'audio_samples', file)); 20 | }); 21 | } catch (error) { 22 | console.error(error); 23 | } 24 | 25 | console.log('... Done!'); 26 | -------------------------------------------------------------------------------- /binding/web/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Cobra } from './cobra'; 2 | import { CobraWorker } from './cobra_worker'; 3 | 4 | import { 5 | CobraOptions, 6 | CobraWorkerInitRequest, 7 | CobraWorkerProcessRequest, 8 | CobraWorkerReleaseRequest, 9 | CobraWorkerRequest, 10 | CobraWorkerInitResponse, 11 | CobraWorkerProcessResponse, 12 | CobraWorkerReleaseResponse, 13 | CobraWorkerFailureResponse, 14 | CobraWorkerResponse, 15 | } from './types'; 16 | 17 | import cobraWasm from '../lib/pv_cobra.wasm'; 18 | import cobraWasmSimd from '../lib/pv_cobra_simd.wasm'; 19 | 20 | import * as CobraErrors from './cobra_errors'; 21 | 22 | Cobra.setWasm(cobraWasm); 23 | Cobra.setWasmSimd(cobraWasmSimd); 24 | CobraWorker.setWasm(cobraWasm); 25 | CobraWorker.setWasmSimd(cobraWasmSimd); 26 | 27 | export { 28 | Cobra, 29 | CobraOptions, 30 | CobraWorker, 31 | CobraWorkerInitRequest, 32 | CobraWorkerProcessRequest, 33 | CobraWorkerReleaseRequest, 34 | CobraWorkerRequest, 35 | CobraWorkerInitResponse, 36 | CobraWorkerProcessResponse, 37 | CobraWorkerReleaseResponse, 38 | CobraWorkerFailureResponse, 39 | CobraWorkerResponse, 40 | CobraErrors, 41 | }; 42 | -------------------------------------------------------------------------------- /binding/web/src/types.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022-2023 Picovoice Inc. 3 | 4 | You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | file accompanying this source. 6 | 7 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | import { CobraError } from "./cobra_errors"; 13 | 14 | export enum PvStatus { 15 | SUCCESS = 10000, 16 | OUT_OF_MEMORY, 17 | IO_ERROR, 18 | INVALID_ARGUMENT, 19 | STOP_ITERATION, 20 | KEY_ERROR, 21 | INVALID_STATE, 22 | RUNTIME_ERROR, 23 | ACTIVATION_ERROR, 24 | ACTIVATION_LIMIT_REACHED, 25 | ACTIVATION_THROTTLED, 26 | ACTIVATION_REFUSED, 27 | } 28 | 29 | export type CobraOptions = { 30 | /** @defaultValue undefined */ 31 | processErrorCallback?: (error: CobraError) => void; 32 | }; 33 | 34 | export type CobraWorkerInitRequest = { 35 | command: 'init'; 36 | accessKey: string; 37 | wasm: string; 38 | wasmSimd: string; 39 | sdk: string; 40 | options: CobraOptions; 41 | }; 42 | 43 | export type CobraWorkerProcessRequest = { 44 | command: 'process'; 45 | inputFrame: Int16Array; 46 | }; 47 | 48 | export type CobraWorkerReleaseRequest = { 49 | command: 'release'; 50 | }; 51 | 52 | export type CobraWorkerRequest = 53 | | CobraWorkerInitRequest 54 | | CobraWorkerProcessRequest 55 | | CobraWorkerReleaseRequest; 56 | 57 | export type CobraWorkerFailureResponse = { 58 | command: 'failed' | 'error'; 59 | status: PvStatus; 60 | shortMessage: string; 61 | messageStack: string[]; 62 | }; 63 | 64 | export type CobraWorkerInitResponse = 65 | | CobraWorkerFailureResponse 66 | | { 67 | command: 'ok'; 68 | frameLength: number; 69 | sampleRate: number; 70 | version: string; 71 | }; 72 | 73 | export type CobraWorkerProcessResponse = 74 | | CobraWorkerFailureResponse 75 | | { 76 | command: 'ok'; 77 | voiceProbability: number; 78 | }; 79 | 80 | export type CobraWorkerReleaseResponse = 81 | | CobraWorkerFailureResponse 82 | | { 83 | command: 'ok'; 84 | }; 85 | 86 | export type CobraWorkerResponse = 87 | | CobraWorkerInitResponse 88 | | CobraWorkerProcessResponse 89 | | CobraWorkerReleaseResponse; 90 | -------------------------------------------------------------------------------- /binding/web/test/cobra_perf.test.ts: -------------------------------------------------------------------------------- 1 | import { Cobra, CobraWorker } from "../"; 2 | 3 | const ACCESS_KEY = Cypress.env('ACCESS_KEY'); 4 | const NUM_TEST_ITERATIONS = Number(Cypress.env('NUM_TEST_ITERATIONS')); 5 | const PROC_PERFORMANCE_THRESHOLD_SEC = Number(Cypress.env('PROC_PERFORMANCE_THRESHOLD_SEC')); 6 | 7 | async function testPerformance( 8 | instance: typeof Cobra | typeof CobraWorker, 9 | inputPcm: Int16Array 10 | ) { 11 | const initPerfResults: number[] = []; 12 | const procPerfResults: number[] = []; 13 | 14 | for (let j = 0; j < NUM_TEST_ITERATIONS; j++) { 15 | let start = Date.now(); 16 | 17 | let numSamples = 0; 18 | let processed = 0; 19 | 20 | const cobra = await instance.create( 21 | ACCESS_KEY, 22 | () => { 23 | processed += 1; 24 | } 25 | ); 26 | 27 | let end = Date.now(); 28 | initPerfResults.push((end - start) / 1000); 29 | 30 | numSamples = Math.floor(inputPcm.length / cobra.frameLength); 31 | 32 | const waitUntil = (): Promise => 33 | new Promise(resolve => { 34 | setInterval(() => { 35 | if (numSamples === processed) { 36 | resolve(); 37 | } 38 | }, 100); 39 | }); 40 | 41 | start = Date.now(); 42 | for ( 43 | let i = 0; 44 | i < inputPcm.length - cobra.frameLength + 1; 45 | i += cobra.frameLength 46 | ) { 47 | await cobra.process(inputPcm.slice(i, i + cobra.frameLength)); 48 | } 49 | await waitUntil(); 50 | end = Date.now(); 51 | procPerfResults.push((end - start) / 1000); 52 | 53 | if (cobra instanceof CobraWorker) { 54 | cobra.terminate(); 55 | } else { 56 | await cobra.release(); 57 | } 58 | } 59 | 60 | const procAvgPerf = procPerfResults.reduce((a, b) => a + b) / NUM_TEST_ITERATIONS; 61 | 62 | // eslint-disable-next-line no-console 63 | console.log(`Average proc performance: ${procAvgPerf} seconds`); 64 | 65 | expect(procAvgPerf).to.be.lessThan(PROC_PERFORMANCE_THRESHOLD_SEC); 66 | } 67 | 68 | describe('Cobra binding performance test', () => { 69 | Cypress.config('defaultCommandTimeout', 120000); 70 | 71 | for (const instance of [Cobra, CobraWorker]) { 72 | const instanceString = (instance === CobraWorker) ? 'worker' : 'main'; 73 | 74 | it(`should be lower than performance threshold (${instanceString})`, () => { 75 | cy.getFramesFromFile('audio_samples/sample.wav').then( async inputPcm => { 76 | await testPerformance(instance, inputPcm); 77 | }); 78 | }); 79 | } 80 | }); 81 | -------------------------------------------------------------------------------- /binding/web/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": true, 4 | "allowSyntheticDefaultImports": true, 5 | "downlevelIteration": true, 6 | "isolatedModules": false, 7 | "noImplicitAny": false, 8 | "lib": ["es2015", "esnext", "dom"], 9 | "module": "esnext", 10 | "moduleResolution": "node", 11 | "noEmit": false, 12 | "outDir": "./dist", 13 | "removeComments": false, 14 | "resolveJsonModule": true, 15 | "sourceMap": true, 16 | "strict": true, 17 | "target": "esnext", 18 | "types": ["node"] 19 | }, 20 | "include": ["src", "module.d.ts"], 21 | "exclude": ["node_modules"] 22 | } 23 | -------------------------------------------------------------------------------- /demo/android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | .settings 17 | .classpath 18 | .project -------------------------------------------------------------------------------- /demo/android/Activity/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/ 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | release 10 | test_resources -------------------------------------------------------------------------------- /demo/android/Activity/README.md: -------------------------------------------------------------------------------- 1 | # Android Activity Demo 2 | 3 | This Android demo runs Cobra in the foreground (i.e., when the app is in focus). 4 | 5 | ## Setup 6 | 7 | 1. Replace `String ACCESS_KEY = "..."` inside 8 | [MainActivity.java](cobra-activity-demo-app/src/main/java/ai/picovoice/cobraactivitydemo/MainActivity.java) 9 | with your AccessKey generated by [Picovoice Console](https://console.picovoice.ai/). 10 | 11 | ```java 12 | private static final String ACCESS_KEY = "YOUR_ACCESS_KEY_HERE"; 13 | ``` 14 | 15 | 2. Add `pvTestingAccessKey = "..."` inside `local.properties` 16 | with your AccessKey generated by [Picovoice Console](https://console.picovoice.ai/). 17 | 18 | ```console 19 | pvTestingAccessKey=YOUR_ACCESS_KEY_HERE 20 | ``` 21 | 22 | ## Usage 23 | 24 | Launch the demo on your phone using Android Studio. 25 | 26 | 1. Press the start button 27 | 2. Start talking. The app background will change to indicate that voice activity was detected above the threshold. 28 | -------------------------------------------------------------------------------- /demo/android/Activity/build.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | defaultTargetSdkVersion = 33 3 | } 4 | 5 | buildscript { 6 | repositories { 7 | google() 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:7.4.2' 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | google() 18 | mavenCentral() 19 | } 20 | } 21 | 22 | tasks.register('clean', Delete) { 23 | delete rootProject.buildDir 24 | } 25 | -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/android/Activity/cobra-activity-demo-app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/drawable/button_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/drawable/button_disabled.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/drawable/error_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/android/Activity/cobra-activity-demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #377DFF 4 | #25187E 5 | #ff0e0e 6 | #76838e 7 | 8 | -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Cobra Activity 3 | Voice Detected! 4 | 0.8 5 | 6 | -------------------------------------------------------------------------------- /demo/android/Activity/cobra-activity-demo-app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /demo/android/Activity/copy_test_resources.sh: -------------------------------------------------------------------------------- 1 | if [ ! -d "./cobra-activity-demo-app/src/androidTest/assets/test_resources/audio" ] 2 | then 3 | echo "Creating test audio samples directory..." 4 | mkdir -p ./cobra-activity-demo-app/src/androidTest/assets/test_resources/audio 5 | fi 6 | 7 | echo "Copying test audio samples..." 8 | cp ../../../res/audio/sample.wav ./cobra-activity-demo-app/src/androidTest/assets/test_resources/audio/sample.wav 9 | -------------------------------------------------------------------------------- /demo/android/Activity/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | android.nonTransitiveRClass=false 19 | 20 | -------------------------------------------------------------------------------- /demo/android/Activity/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/android/Activity/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /demo/android/Activity/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jul 19 14:23:40 PDT 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /demo/android/Activity/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /demo/android/Activity/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "CobraActivityDemo" 2 | include ':cobra-activity-demo-app' 3 | -------------------------------------------------------------------------------- /demo/android/README.md: -------------------------------------------------------------------------------- 1 | # Android Demos 2 | 3 | ## AccessKey 4 | 5 | Cobra requires a valid Picovoice `AccessKey` at initialization. `AccessKey` acts as your credentials when using Cobra SDKs. 6 | You can get your `AccessKey` for free. Make sure to keep your `AccessKey` secret. 7 | Signup or Login to [Picovoice Console](https://console.picovoice.ai/) to get your `AccessKey`. 8 | 9 | ## Activity 10 | 11 | Copy your AccessKey into the `ACCESS_KEY` variable in `MainActivity.java` before building the demo. 12 | 13 | This demo is intended for applications that need to do voice activity detection when in focus. 14 | -------------------------------------------------------------------------------- /demo/c/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | cmake-build-debug 3 | cmake-build-release -------------------------------------------------------------------------------- /demo/c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | project(cobra_demo_c) 3 | 4 | set(CMAKE_C_STANDARD 99) 5 | set(CMAKE_BUILD_TYPE Release) 6 | add_subdirectory(pvrecorder/project) 7 | 8 | set(COMMON_LIBS dl) 9 | include_directories("${PROJECT_SOURCE_DIR}/../../include") 10 | 11 | add_executable( 12 | cobra_demo_file 13 | cobra_demo_file.c) 14 | target_include_directories(cobra_demo_file PRIVATE dr_libs) 15 | 16 | add_executable( 17 | cobra_demo_mic 18 | cobra_demo_mic.c 19 | $) 20 | target_include_directories(cobra_demo_mic PRIVATE pvrecorder/project/include) 21 | 22 | if (NOT WIN32) 23 | target_link_libraries( 24 | cobra_demo_mic 25 | pthread 26 | m 27 | ${COMMON_LIBS}) 28 | target_link_libraries(cobra_demo_file ${COMMON_LIBS}) 29 | if((${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") AND (UNIX AND NOT APPLE)) 30 | target_link_libraries(cobra_demo_mic atomic) 31 | endif() 32 | endif() 33 | -------------------------------------------------------------------------------- /demo/c/Preload.CMake: -------------------------------------------------------------------------------- 1 | if(WIN32) 2 | set(CMAKE_GENERATOR "MinGW Makefiles" CACHE STRING "" FORCE) 3 | else() 4 | set(CMAKE_GENERATOR "Unix Makefiles" CACHE STRING "" FORCE) 5 | endif() -------------------------------------------------------------------------------- /demo/c/test/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/c/test/requirements.txt -------------------------------------------------------------------------------- /demo/c/test/test_cobra_c.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023 Picovoice Inc. 3 | # 4 | # You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | # file accompanying this source. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | # specific language governing permissions and limitations under the License. 10 | # 11 | 12 | import os.path 13 | import subprocess 14 | import sys 15 | import unittest 16 | 17 | from test_util import * 18 | 19 | 20 | class CobraCTestCase(unittest.TestCase): 21 | 22 | @classmethod 23 | def setUpClass(cls): 24 | cls._access_key = sys.argv[1] 25 | cls._platform = sys.argv[2] 26 | cls._arch = "" if len(sys.argv) != 4 else sys.argv[3] 27 | cls._root_dir = os.path.join(os.path.dirname(__file__), "../../..") 28 | 29 | def _get_library_file(self): 30 | return os.path.join( 31 | self._root_dir, 32 | "lib", 33 | self._platform, 34 | self._arch, 35 | "libpv_cobra." + get_lib_ext(self._platform) 36 | ) 37 | 38 | 39 | def test_cobra(self): 40 | args = [ 41 | os.path.join(os.path.dirname(__file__), "../build/cobra_demo_file"), 42 | "-a", self._access_key, 43 | "-l", self._get_library_file(), 44 | "-w", os.path.join(self._root_dir, "res", "audio", "sample.wav"), 45 | ] 46 | process = subprocess.Popen(args, stderr=subprocess.PIPE, stdout=subprocess.PIPE) 47 | stdout, stderr = process.communicate() 48 | self.assertEqual(process.poll(), 0) 49 | self.assertEqual(stderr.decode('utf-8'), '') 50 | 51 | 52 | if __name__ == '__main__': 53 | if len(sys.argv) < 3 or len(sys.argv) > 4: 54 | print("usage: test_cobra_c.py ${AccessKey} ${Platform} [${Arch}]") 55 | exit(1) 56 | unittest.main(argv=sys.argv[:1]) 57 | -------------------------------------------------------------------------------- /demo/c/test/test_util.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023 Picovoice Inc. 3 | # 4 | # You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 5 | # file accompanying this source. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | # specific language governing permissions and limitations under the License. 10 | # 11 | 12 | import json 13 | import os 14 | 15 | 16 | def get_lib_ext(platform): 17 | if platform == "windows": 18 | return "dll" 19 | elif platform == "mac": 20 | return "dylib" 21 | else: 22 | return "so" 23 | -------------------------------------------------------------------------------- /demo/dotnet/.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | CobraDemo/bin/** 3 | CobraDemo/obj/** 4 | CobraDemo/Properties/** 5 | *.user 6 | -------------------------------------------------------------------------------- /demo/dotnet/CobraDemo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32929.385 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CobraDemo", "CobraDemo\CobraDemo.csproj", "{5AE5D341-BE0B-4E35-A4F0-CBCD339C844E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | FileDemo.Debug|AnyCPU = FileDemo.Debug|AnyCPU 11 | FileDemo.Release|AnyCPU = FileDemo.Release|AnyCPU 12 | MicDemo.Debug|AnyCPU = MicDemo.Debug|AnyCPU 13 | MicDemo.Release|AnyCPU = MicDemo.Release|AnyCPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {5AE5D341-BE0B-4E35-A4F0-CBCD339C844E}.FileDemo.Debug|AnyCPU.ActiveCfg = FileDemo.Debug|Any CPU 17 | {5AE5D341-BE0B-4E35-A4F0-CBCD339C844E}.FileDemo.Debug|AnyCPU.Build.0 = FileDemo.Debug|Any CPU 18 | {5AE5D341-BE0B-4E35-A4F0-CBCD339C844E}.FileDemo.Release|AnyCPU.ActiveCfg = FileDemo.Release|Any CPU 19 | {5AE5D341-BE0B-4E35-A4F0-CBCD339C844E}.FileDemo.Release|AnyCPU.Build.0 = FileDemo.Release|Any CPU 20 | {5AE5D341-BE0B-4E35-A4F0-CBCD339C844E}.MicDemo.Debug|AnyCPU.ActiveCfg = MicDemo.Debug|Any CPU 21 | {5AE5D341-BE0B-4E35-A4F0-CBCD339C844E}.MicDemo.Debug|AnyCPU.Build.0 = MicDemo.Debug|Any CPU 22 | {5AE5D341-BE0B-4E35-A4F0-CBCD339C844E}.MicDemo.Release|AnyCPU.ActiveCfg = MicDemo.Release|Any CPU 23 | {5AE5D341-BE0B-4E35-A4F0-CBCD339C844E}.MicDemo.Release|AnyCPU.Build.0 = MicDemo.Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {718FE840-6F27-4751-957F-382E9780BBFC} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /demo/dotnet/CobraDemo/CobraDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net8.0 6 | FileDemo.Debug;FileDemo.Release;MicDemo.Debug;MicDemo.Release 7 | 8 | 9 | 10 | CobraDemo.FileDemo 11 | CobraFileDemo 12 | CobraFileDemo 13 | 14 | 15 | 16 | CobraDemo.MicDemo 17 | CobraMicDemo 18 | CobraMicDemo 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /demo/ios/.gitignore: -------------------------------------------------------------------------------- 1 | # Exclude the build directory 2 | build/* 3 | 4 | # Exclude temp nibs and swap files 5 | *~.nib 6 | *.swp 7 | 8 | # Exclude OS X folder attributes 9 | .DS_Store 10 | 11 | # Exclude user-specific XCode 3 and 4 files 12 | *.mode1 13 | *.mode1v3 14 | *.mode2v3 15 | *.perspective 16 | *.perspectivev3 17 | *.pbxuser 18 | xcuserdata 19 | Pods 20 | ddp -------------------------------------------------------------------------------- /demo/ios/CobraDemo/.gitignore: -------------------------------------------------------------------------------- 1 | # Exclude the build directory 2 | build/* 3 | 4 | # Exclude temp nibs and swap files 5 | *~.nib 6 | *.swp 7 | 8 | # Exclude OS X folder attributes 9 | .DS_Store 10 | 11 | # Exclude user-specific XCode 3 and 4 files 12 | *.mode1 13 | *.mode1v3 14 | *.mode2v3 15 | *.perspective 16 | *.perspectivev3 17 | *.pbxuser 18 | *.xcworkspace 19 | project.xcworkspace 20 | contents.xcworkspacedata 21 | xcuserdata 22 | Pods -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-1024.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-20.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-20@2x.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-20@3x.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-29.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-29@2x.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-29@3x.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-40.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-40@2x.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-40@3x.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-60@2x.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-60@3x.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-76.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-76@2x.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/demo/ios/CobraDemo/CobraDemo/Assets.xcassets/AppIcon.appiconset/pv_circle_512-83.5@2x.png -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/CobraDemoApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Picovoice Inc. 3 | // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" 4 | // file accompanying this source. 5 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 6 | // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 7 | // specific language governing permissions and limitations under the License. 8 | // 9 | 10 | import SwiftUI 11 | 12 | @main 13 | struct CobraDemoApp: App { 14 | var body: some Scene { 15 | WindowGroup { 16 | ContentView() 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /demo/ios/CobraDemo/CobraDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSMicrophoneUsageDescription 24 | For voice activity detection 25 | UIApplicationSceneManifest 26 | 27 | UIApplicationSupportsMultipleScenes 28 | 29 | 30 | UIApplicationSupportsIndirectInputEvents 31 | 32 | UILaunchScreen 33 | 34 | UIRequiredDeviceCapabilities 35 | 36 | armv7 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationPortraitUpsideDown 42 | 43 | UISupportedInterfaceOrientations~ipad 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /demo/ios/README.md: -------------------------------------------------------------------------------- 1 | # Cobra iOS Demo 2 | 3 | ## AccessKey 4 | 5 | Cobra requires a valid Picovoice `AccessKey` at initialization. `AccessKey` acts as your credentials when using Cobra SDKs. 6 | You can get your `AccessKey` for free. Make sure to keep your `AccessKey` secret. 7 | Signup or Login to [Picovoice Console](https://console.picovoice.ai/) to get your `AccessKey`. 8 | 9 | ## Setup 10 | 11 | 1. Before building the demo app, run the following from this directory to install the Cobra Cocoapod: 12 | ```console 13 | pod install 14 | ``` 15 | 2. Replace `let ACCESS_KEY = "..."` inside [`ViewModel.swift`](CobraDemo/CobraDemo/ViewModel.swift) with your AccessKey. 16 | ```swift 17 | private let ACCESS_KEY = "YOUR_ACCESS_KEY_HERE" 18 | ``` 19 | 20 | ## Usage 21 | 22 | Open the CobraDemo XCode project and build. Launch the demo on a simulator or an physical iOS device. 23 | 24 | 1. Press the Start button 25 | 2. Start talking. The app background will change to indicate that voice activity was detected above the threshold. 26 | -------------------------------------------------------------------------------- /demo/nodejs/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | lib 3 | resources 4 | package-lock.json 5 | -------------------------------------------------------------------------------- /demo/nodejs/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /demo/nodejs/README.md: -------------------------------------------------------------------------------- 1 | # Cobra Voice Activity Detection Demos 2 | 3 | Made in Vancouver, Canada by [Picovoice](https://picovoice.ai) 4 | 5 | ## Cobra 6 | 7 | Cobra is an on-device voice activity detection engine. Cobra is: 8 | 9 | - Private; All voice processing runs locally. 10 | - Accurate [[1]](https://picovoice.ai/docs/benchmark/vad/#results) 11 | - Cross-Platform: 12 | - Linux (x86_64), macOS (x86_64, arm64), and Windows (x86_64, arm64) 13 | - Android and iOS 14 | - Chrome, Safari, Firefox, and Edge 15 | - Raspberry Pi (3, 4, 5) 16 | 17 | ## Compatibility 18 | 19 | - Node.js 18+ 20 | - Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64, arm64), and Raspberry Pi (3, 4, 5). 21 | 22 | ## Installation 23 | 24 | ```console 25 | npm install -g @picovoice/cobra-node-demo 26 | ``` 27 | 28 | ## AccessKey 29 | 30 | Cobra requires a valid Picovoice `AccessKey` at initialization. `AccessKey` acts as your credentials when using Cobra SDKs. 31 | You can get your `AccessKey` for free. Make sure to keep your `AccessKey` secret. 32 | Signup or Login to [Picovoice Console](https://console.picovoice.ai/) to get your `AccessKey`. 33 | 34 | ## Usage 35 | 36 | ### File Demo 37 | 38 | Run the following in the terminal: 39 | 40 | ```console 41 | cobra-file-demo --access_key ${ACCESS_KEY} --input_audio_file_path ${AUDIO_PATH} 42 | ``` 43 | 44 | Replace `${ACCESS_KEY}` with yours obtained from Picovoice Console and `${AUDIO_PATH}` with a path to an audio file you 45 | wish to use for voice activity detection. 46 | 47 | The threshold of the engine can be tuned using the `threshold` input argument: 48 | 49 | ```console 50 | cobra-file-demo --access_key ${ACCESS_KEY} --input_audio_file_path ${AUDIO_PATH} --threshold ${DETECTION_THRESHOLD} 51 | ``` 52 | 53 | Threshold is a floating point number within `[0, 1]`. A higher threshold reduces the miss rate at the cost of increased false alarm rate. 54 | 55 | ### Microphone Demo 56 | 57 | You need a working microphone connected to your machine for this demo. Run the following in the terminal: 58 | 59 | ```console 60 | cobra-mic-demo --access_key ${ACCESS_KEY} 61 | ``` 62 | 63 | Replace `${ACCESS_KEY}` with yours obtained from Picovoice Console. 64 | 65 | To stop recording, press `Ctrl + C` or hit the `ENTER` key. 66 | -------------------------------------------------------------------------------- /demo/nodejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@picovoice/cobra-node-demo", 3 | "version": "2.0.4", 4 | "description": "Picovoice Cobra Node.js file-based and microphone demos", 5 | "scripts": { 6 | "file": "node file.js", 7 | "mic": "node mic.js" 8 | }, 9 | "bin": { 10 | "cobra-file-demo": "./file.js", 11 | "cobra-mic-demo": "./mic.js" 12 | }, 13 | "keywords": [ 14 | "cobra, picovoice, voice activity detection, offline, private, voice ai, microphone, mic, realtime" 15 | ], 16 | "author": "Picovoice Inc.", 17 | "license": "Apache-2.0", 18 | "dependencies": { 19 | "@picovoice/cobra-node": "=2.0.4", 20 | "@picovoice/pvrecorder-node": "~1.2.6", 21 | "commander": "^6.1.0", 22 | "readline": "^1.3.0", 23 | "wavefile": "^11.0.0" 24 | }, 25 | "homepage": "https://picovoice.ai/platform/cobra/", 26 | "repository": { 27 | "type": "git", 28 | "url": "https://github.com/Picovoice/cobra.git", 29 | "directory": "demo/nodejs" 30 | }, 31 | "engines": { 32 | "node": ">=18.0.0" 33 | }, 34 | "cpu": [ 35 | "!ia32", 36 | "!mips", 37 | "!ppc", 38 | "!ppc64" 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /demo/nodejs/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@picovoice/cobra-node@=2.0.4": 6 | version "2.0.4" 7 | resolved "https://registry.yarnpkg.com/@picovoice/cobra-node/-/cobra-node-2.0.4.tgz#ae8b17e343043ba06eeb8d0fb1bcc7f018ff5957" 8 | integrity sha512-A5ofpxQ1g1NiIbRcf+x+DJqjFuiecafBKeVFlzf56Utk03KXBMAnQWdco2H7C8X1h7GBu4y/XjUaD2RpZmKYnQ== 9 | 10 | "@picovoice/pvrecorder-node@~1.2.6": 11 | version "1.2.6" 12 | resolved "https://registry.yarnpkg.com/@picovoice/pvrecorder-node/-/pvrecorder-node-1.2.6.tgz#6b6ea8b38892b916c9e3682342fa144c710e1aa0" 13 | integrity sha512-AC8vqo+GWSGquMyyv0rhP68fjCxVe0kCo9QEq5mgBv7qHV2qVH5rm6ONPQQ6rmYD0SfppFaRP0yZKhPs1FhADQ== 14 | 15 | commander@^6.1.0: 16 | version "6.2.1" 17 | resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" 18 | integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== 19 | 20 | readline@^1.3.0: 21 | version "1.3.0" 22 | resolved "https://registry.yarnpkg.com/readline/-/readline-1.3.0.tgz#c580d77ef2cfc8752b132498060dc9793a7ac01c" 23 | integrity sha512-k2d6ACCkiNYz222Fs/iNze30rRJ1iIicW7JuX/7/cozvih6YCkFZH+J6mAFDVgv0dRBaAyr4jDqC95R2y4IADg== 24 | 25 | wavefile@^11.0.0: 26 | version "11.0.0" 27 | resolved "https://registry.yarnpkg.com/wavefile/-/wavefile-11.0.0.tgz#9302165874327ff63a704d00b154c753eaa1b8e7" 28 | integrity sha512-/OBiAALgWU24IG7sC84cDO/KfFuvajWc5Uec0oV2zrpOOZZDgGdOwHwgEzOrwh8jkubBk7PtZfQBIcI1OaE5Ng== 29 | -------------------------------------------------------------------------------- /demo/python/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | dist 3 | MANIFEST.in 4 | pvcobrademo 5 | pvcobrademo.egg-info -------------------------------------------------------------------------------- /demo/python/requirements.txt: -------------------------------------------------------------------------------- 1 | pvcobra==2.0.5 2 | pvrecorder==1.2.4 3 | -------------------------------------------------------------------------------- /demo/python/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | 4 | import setuptools 5 | 6 | os.system('git clean -dfx') 7 | 8 | package_folder = os.path.join(os.path.dirname(__file__), 'pvcobrademo') 9 | os.mkdir(package_folder) 10 | 11 | shutil.copy(os.path.join(os.path.dirname(__file__), '../../LICENSE'), package_folder) 12 | 13 | shutil.copy( 14 | os.path.join(os.path.dirname(__file__), 'cobra_demo_file.py'), 15 | os.path.join(package_folder, 'cobra_demo_file.py')) 16 | 17 | shutil.copy( 18 | os.path.join(os.path.dirname(__file__), 'cobra_demo_mic.py'), 19 | os.path.join(package_folder, 'cobra_demo_mic.py')) 20 | 21 | with open(os.path.join(os.path.dirname(__file__), 'MANIFEST.in'), 'w') as f: 22 | f.write('include pvcobrademo/LICENSE\n') 23 | f.write('include pvcobrademo/cobra_demo_file.py\n') 24 | f.write('include pvcobrademo/cobra_demo_mic.py\n') 25 | 26 | with open(os.path.join(os.path.dirname(__file__), 'README.md'), 'r') as f: 27 | long_description = f.read() 28 | 29 | with open(os.path.join(os.path.dirname(__file__), "requirements.txt"), "r") as f: 30 | dependencies = f.read().strip().splitlines() 31 | 32 | setuptools.setup( 33 | name="pvcobrademo", 34 | version="2.0.5", 35 | author="Picovoice", 36 | author_email="hello@picovoice.ai", 37 | description="Cobra voice activity detection (VAD) engine demos.", 38 | long_description=long_description, 39 | long_description_content_type="text/markdown", 40 | url="https://github.com/Picovoice/cobra", 41 | packages=["pvcobrademo"], 42 | install_requires=dependencies, 43 | include_package_data=True, 44 | classifiers=[ 45 | "Development Status :: 5 - Production/Stable", 46 | "Intended Audience :: Developers", 47 | "License :: OSI Approved :: Apache Software License", 48 | "Operating System :: OS Independent", 49 | "Programming Language :: Python :: 3", 50 | "Topic :: Multimedia :: Sound/Audio :: Speech" 51 | ], 52 | entry_points=dict( 53 | console_scripts=[ 54 | 'cobra_demo_file=pvcobrademo.cobra_demo_file:main', 55 | 'cobra_demo_mic=pvcobrademo.cobra_demo_mic:main', 56 | ], 57 | ), 58 | python_requires='>=3.9', 59 | keywords="voice activity detection engine, VAD", 60 | ) 61 | -------------------------------------------------------------------------------- /demo/rust/filedemo/.gitignore: -------------------------------------------------------------------------------- 1 | target/ -------------------------------------------------------------------------------- /demo/rust/filedemo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pv_cobra_filedemo" 3 | version = "0.1.1" 4 | edition = "2018" 5 | 6 | [dependencies] 7 | chrono = "0.4.23" 8 | clap = "2.33.3" 9 | hound = "3.5.0" 10 | itertools = "0.10.1" 11 | pv_cobra = "=2.0.3" 12 | -------------------------------------------------------------------------------- /demo/rust/micdemo/.gitignore: -------------------------------------------------------------------------------- 1 | target/ -------------------------------------------------------------------------------- /demo/rust/micdemo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pv_cobra_micdemo" 3 | version = "0.1.2" 4 | edition = "2018" 5 | 6 | [dependencies] 7 | chrono = "0.4.23" 8 | clap = "2.33.3" 9 | ctrlc = "3.1.9" 10 | hound = "3.5.0" 11 | itertools = "0.10.1" 12 | pv_cobra = "=2.0.3" 13 | pv_recorder = "=1.2.1" 14 | -------------------------------------------------------------------------------- /demo/web/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .rts2_cache/ 3 | .idea/ 4 | dist/ 5 | *.log 6 | .DS_Store 7 | -------------------------------------------------------------------------------- /demo/web/.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | .DS_Store -------------------------------------------------------------------------------- /demo/web/.prettierignore: -------------------------------------------------------------------------------- 1 | # Ignore artifacts: 2 | build 3 | coverage 4 | -------------------------------------------------------------------------------- /demo/web/.prettierrc: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /demo/web/README.md: -------------------------------------------------------------------------------- 1 | # cobra-web-demo 2 | 3 | This is a basic demo to show how to use Cobra for web browsers, using the IIFE version of the library (i.e. an HTML script tag). 4 | It instantiates a Cobra worker engine and uses it with the 5 | [@picovoice/web-voice-processor](https://www.npmjs.com/package/@picovoice/web-voice-processor) 6 | to access (and automatically downsample) microphone audio. 7 | 8 | ## AccessKey 9 | 10 | Cobra requires a valid Picovoice `AccessKey` at initialization. `AccessKey` acts as your credentials when using Cobra SDKs. 11 | You can get your `AccessKey` for free. Make sure to keep your `AccessKey` secret. 12 | Signup or Login to [Picovoice Console](https://console.picovoice.ai/) to get your `AccessKey`. 13 | 14 | ## Install & run 15 | 16 | 1. Use `yarn` or `npm` to install the dependencies 17 | 1. Run `start` script to start a local web server hosting the demo. 18 | 19 | ```console 20 | yarn 21 | yarn start 22 | ``` 23 | 24 | (or) 25 | 26 | ```console 27 | npm install 28 | npm run start 29 | ``` 30 | 31 | Open `localhost:5000` in your web browser, as hinted at in the output: 32 | 33 | ```console 34 | Available on: 35 | http://localhost:5000 36 | Hit CTRL-C to stop the server 37 | ``` 38 | 39 | Wait until Cobra and the WebVoiceProcessor have initialized. Start speaking and Cobra will display voice probability on the screen. 40 | -------------------------------------------------------------------------------- /demo/web/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import globals from "globals"; 2 | import pluginJs from "@eslint/js"; 3 | 4 | /** @type {import('eslint').Linter.Config[]} */ 5 | export default [ 6 | { files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } }, 7 | { 8 | languageOptions: { 9 | globals: { 10 | ...globals.browser, 11 | ...globals.node, 12 | CobraWeb: "readonly", 13 | WebVoiceProcessor: "readonly", 14 | }, 15 | }, 16 | }, 17 | pluginJs.configs.recommended, 18 | { 19 | rules: { 20 | "no-unused-vars": ["off"], 21 | }, 22 | }, 23 | ]; 24 | -------------------------------------------------------------------------------- /demo/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |

Cobra Web Demo - worker

11 |

12 | This demo uses Cobra for Web and the WebVoiceProcessor packages to create 13 | an instance of Cobra that listens for voice activity and outputs them to 14 | the page. After entering the AccessKey, click the "run Cobra" button. 15 |

16 | 17 | 21 | 22 | 28 |
29 | 30 |
31 | 32 |
33 |

34 | 43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /demo/web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cobra-web-demo", 3 | "version": "2.0.0", 4 | "description": "A basic demo to show how to use Cobra for web browsers, using the IIFE version of the library", 5 | "main": "index.js", 6 | "private": true, 7 | "scripts": { 8 | "start": "yarn run http-server -a localhost -p 5000" 9 | }, 10 | "keywords": [ 11 | "Picovoice", 12 | "Cobra", 13 | "browser", 14 | "voice ai", 15 | "voice activity detection" 16 | ], 17 | "author": "Picovoice Inc", 18 | "license": "Apache-2.0", 19 | "dependencies": { 20 | "@picovoice/cobra-web": "~2.0.3", 21 | "@picovoice/web-voice-processor": "~4.0.8" 22 | }, 23 | "devDependencies": { 24 | "@eslint/js": "^9.22.0", 25 | "eslint": "^9.22.0", 26 | "globals": "^16.0.0", 27 | "http-server": "^14.0.0", 28 | "prettier": "3.5.1" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /demo/web/scripts/cobra.js: -------------------------------------------------------------------------------- 1 | function writeMessage(message) { 2 | console.log(message); 3 | document.getElementById("status").innerHTML = message; 4 | } 5 | 6 | function writeVoiceProbability(message, value) { 7 | document.getElementById("voiceProbabilityText").innerHTML = message; 8 | document.getElementById("voiceProbabilityRange").value = value * 100; 9 | } 10 | 11 | function voiceProbabilityCallback(voiceProbability) { 12 | const timestamp = new Date(); 13 | writeVoiceProbability( 14 | `Voice detected with probability of ${voiceProbability.toFixed(2)} at ${timestamp.toString()}`, 15 | voiceProbability, 16 | ); 17 | } 18 | 19 | async function startCobra(accessKey) { 20 | writeMessage("Cobra is loading. Please wait..."); 21 | let cobra = null; 22 | try { 23 | cobra = await CobraWeb.CobraWorker.create( 24 | accessKey, 25 | voiceProbabilityCallback, 26 | ); 27 | } catch (error) { 28 | writeMessage(error); 29 | throw new Error(error); 30 | } 31 | writeMessage("Cobra worker ready!"); 32 | 33 | writeMessage( 34 | "WebVoiceProcessor initializing. Microphone permissions requested ...", 35 | ); 36 | 37 | try { 38 | WebVoiceProcessor.WebVoiceProcessor.subscribe(cobra); 39 | writeMessage("WebVoiceProcessor ready and listening!"); 40 | } catch (e) { 41 | writeMessage("WebVoiceProcessor failed to initialize: " + e); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/android/arm64-v8a/libpv_cobra.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/android/arm64-v8a/libpv_cobra.so -------------------------------------------------------------------------------- /lib/android/armeabi-v7a/libpv_cobra.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/android/armeabi-v7a/libpv_cobra.so -------------------------------------------------------------------------------- /lib/android/x86/libpv_cobra.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/android/x86/libpv_cobra.so -------------------------------------------------------------------------------- /lib/android/x86_64/libpv_cobra.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/android/x86_64/libpv_cobra.so -------------------------------------------------------------------------------- /lib/ios/PvCobra.xcframework/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AvailableLibraries 6 | 7 | 8 | BinaryPath 9 | PvCobra.framework/PvCobra 10 | LibraryIdentifier 11 | ios-arm64 12 | LibraryPath 13 | PvCobra.framework 14 | SupportedArchitectures 15 | 16 | arm64 17 | 18 | SupportedPlatform 19 | ios 20 | 21 | 22 | BinaryPath 23 | PvCobra.framework/PvCobra 24 | LibraryIdentifier 25 | ios-arm64_x86_64-simulator 26 | LibraryPath 27 | PvCobra.framework 28 | SupportedArchitectures 29 | 30 | arm64 31 | x86_64 32 | 33 | SupportedPlatform 34 | ios 35 | SupportedPlatformVariant 36 | simulator 37 | 38 | 39 | CFBundlePackageType 40 | XFWK 41 | XCFrameworkFormatVersion 42 | 1.0 43 | 44 | 45 | -------------------------------------------------------------------------------- /lib/ios/PvCobra.xcframework/ios-arm64/PvCobra.framework/Headers/PvCobra.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | //! Project version number for PvCobra. 4 | FOUNDATION_EXPORT double PvCobraVersionNumber; 5 | 6 | //! Project version string for PvCobra. 7 | FOUNDATION_EXPORT const unsigned char PvCobraVersionString[]; 8 | -------------------------------------------------------------------------------- /lib/ios/PvCobra.xcframework/ios-arm64/PvCobra.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/ios/PvCobra.xcframework/ios-arm64/PvCobra.framework/Info.plist -------------------------------------------------------------------------------- /lib/ios/PvCobra.xcframework/ios-arm64/PvCobra.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module PvCobra { 2 | umbrella header "PvCobra.h" 3 | header "pv_cobra.h" 4 | header "picovoice.h" 5 | export * 6 | module * {export *} 7 | } 8 | -------------------------------------------------------------------------------- /lib/ios/PvCobra.xcframework/ios-arm64/PvCobra.framework/PvCobra: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/ios/PvCobra.xcframework/ios-arm64/PvCobra.framework/PvCobra -------------------------------------------------------------------------------- /lib/ios/PvCobra.xcframework/ios-arm64_x86_64-simulator/PvCobra.framework/Headers/PvCobra.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | //! Project version number for PvCobra. 4 | FOUNDATION_EXPORT double PvCobraVersionNumber; 5 | 6 | //! Project version string for PvCobra. 7 | FOUNDATION_EXPORT const unsigned char PvCobraVersionString[]; 8 | -------------------------------------------------------------------------------- /lib/ios/PvCobra.xcframework/ios-arm64_x86_64-simulator/PvCobra.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/ios/PvCobra.xcframework/ios-arm64_x86_64-simulator/PvCobra.framework/Info.plist -------------------------------------------------------------------------------- /lib/ios/PvCobra.xcframework/ios-arm64_x86_64-simulator/PvCobra.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module PvCobra { 2 | umbrella header "PvCobra.h" 3 | header "pv_cobra.h" 4 | header "picovoice.h" 5 | export * 6 | module * {export *} 7 | } 8 | -------------------------------------------------------------------------------- /lib/ios/PvCobra.xcframework/ios-arm64_x86_64-simulator/PvCobra.framework/PvCobra: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/ios/PvCobra.xcframework/ios-arm64_x86_64-simulator/PvCobra.framework/PvCobra -------------------------------------------------------------------------------- /lib/linux/x86_64/libpv_cobra.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/linux/x86_64/libpv_cobra.so -------------------------------------------------------------------------------- /lib/mac/arm64/libpv_cobra.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/mac/arm64/libpv_cobra.dylib -------------------------------------------------------------------------------- /lib/mac/x86_64/libpv_cobra.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/mac/x86_64/libpv_cobra.dylib -------------------------------------------------------------------------------- /lib/node/linux/x86_64/pv_cobra.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/node/linux/x86_64/pv_cobra.node -------------------------------------------------------------------------------- /lib/node/mac/arm64/pv_cobra.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/node/mac/arm64/pv_cobra.node -------------------------------------------------------------------------------- /lib/node/mac/x86_64/pv_cobra.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/node/mac/x86_64/pv_cobra.node -------------------------------------------------------------------------------- /lib/node/raspberry-pi/cortex-a53-aarch64/pv_cobra.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/node/raspberry-pi/cortex-a53-aarch64/pv_cobra.node -------------------------------------------------------------------------------- /lib/node/raspberry-pi/cortex-a53/pv_cobra.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/node/raspberry-pi/cortex-a53/pv_cobra.node -------------------------------------------------------------------------------- /lib/node/raspberry-pi/cortex-a72-aarch64/pv_cobra.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/node/raspberry-pi/cortex-a72-aarch64/pv_cobra.node -------------------------------------------------------------------------------- /lib/node/raspberry-pi/cortex-a72/pv_cobra.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/node/raspberry-pi/cortex-a72/pv_cobra.node -------------------------------------------------------------------------------- /lib/node/raspberry-pi/cortex-a76-aarch64/pv_cobra.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/node/raspberry-pi/cortex-a76-aarch64/pv_cobra.node -------------------------------------------------------------------------------- /lib/node/raspberry-pi/cortex-a76/pv_cobra.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/node/raspberry-pi/cortex-a76/pv_cobra.node -------------------------------------------------------------------------------- /lib/node/windows/amd64/pv_cobra.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/node/windows/amd64/pv_cobra.node -------------------------------------------------------------------------------- /lib/node/windows/arm64/pv_cobra.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/node/windows/arm64/pv_cobra.node -------------------------------------------------------------------------------- /lib/raspberry-pi/arm11/libpv_cobra.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/raspberry-pi/arm11/libpv_cobra.so -------------------------------------------------------------------------------- /lib/raspberry-pi/cortex-a53-aarch64/libpv_cobra.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/raspberry-pi/cortex-a53-aarch64/libpv_cobra.so -------------------------------------------------------------------------------- /lib/raspberry-pi/cortex-a53/libpv_cobra.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/raspberry-pi/cortex-a53/libpv_cobra.so -------------------------------------------------------------------------------- /lib/raspberry-pi/cortex-a72-aarch64/libpv_cobra.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/raspberry-pi/cortex-a72-aarch64/libpv_cobra.so -------------------------------------------------------------------------------- /lib/raspberry-pi/cortex-a72/libpv_cobra.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/raspberry-pi/cortex-a72/libpv_cobra.so -------------------------------------------------------------------------------- /lib/raspberry-pi/cortex-a76-aarch64/libpv_cobra.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/raspberry-pi/cortex-a76-aarch64/libpv_cobra.so -------------------------------------------------------------------------------- /lib/raspberry-pi/cortex-a76/libpv_cobra.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/raspberry-pi/cortex-a76/libpv_cobra.so -------------------------------------------------------------------------------- /lib/wasm/pv_cobra.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/wasm/pv_cobra.wasm -------------------------------------------------------------------------------- /lib/wasm/pv_cobra_simd.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/wasm/pv_cobra_simd.wasm -------------------------------------------------------------------------------- /lib/windows/amd64/libpv_cobra.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/windows/amd64/libpv_cobra.dll -------------------------------------------------------------------------------- /lib/windows/arm64/libpv_cobra.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/lib/windows/arm64/libpv_cobra.dll -------------------------------------------------------------------------------- /res/.lint/java/checkstyle-10.5.0-all.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/res/.lint/java/checkstyle-10.5.0-all.jar -------------------------------------------------------------------------------- /res/.lint/java/suppress.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /res/.lint/spell-check/.cspell.json: -------------------------------------------------------------------------------- 1 | { 2 | "language": "en", 3 | "dictionaries": [ 4 | "dict" 5 | ], 6 | "dictionaryDefinitions": [ 7 | { 8 | "name": "dict", 9 | "path": "./dict.txt", 10 | "addWords": true 11 | } 12 | ], 13 | "ignorePaths": [ 14 | // submodules 15 | "../../../demo/c/dr_libs/**/*", 16 | "../../../demo/c/pvrecorder/**/*", 17 | 18 | // binaries 19 | "**/*.a", 20 | "**/*.dll", 21 | "**/*.dylib", 22 | "**/*.jar", 23 | "**/*.mp3", 24 | "**/*.node", 25 | "**/*.ppn", 26 | "**/*.pv", 27 | "**/*.so", 28 | "**/*.wasm", 29 | "**/*.wav", 30 | "../../../lib/ios/**/*", 31 | 32 | // android 33 | "**/AndroidManifest.xml", 34 | "**/activity_main.xml", 35 | 36 | // ios 37 | "**/*.xcconfig", 38 | "**/*.podspec", 39 | "**/Podfile", 40 | "**/*.plist", 41 | "**/contents.xcworkspacedata", 42 | "**/*.storyboard", 43 | "**/*.pbxproj", 44 | "**/*.xcscheme", 45 | "**/*.m", 46 | 47 | // java 48 | "**/build.gradle", 49 | "**/gradle-wrapper.properties", 50 | "**/gradle.properties", 51 | "**/gradlew", 52 | "**/gradlew.bat", 53 | "**/proguard-rules.pro", 54 | 55 | // javascript 56 | "**/package.json", 57 | "**/packages-lock.json", 58 | "**/tsconfig.json", 59 | "**/tslint.json", 60 | 61 | // rust 62 | "**/Cargo.toml" 63 | ] 64 | } -------------------------------------------------------------------------------- /res/.lint/spell-check/dict.txt: -------------------------------------------------------------------------------- 1 | aarch 2 | androidx 3 | armv 4 | beaglebone 5 | camelcase 6 | ccobra 7 | chrono 8 | cobraactivitydemo 9 | cocoapod 10 | cocoapods 11 | colour 12 | commandline 13 | Compat 14 | constraintlayout 15 | dmix 16 | downsample 17 | drwav 18 | dtype 19 | dylib 20 | filedemo 21 | iife 22 | improvments 23 | itertools 24 | jetson 25 | libc 26 | libloading 27 | libpv 28 | logf 29 | LPWSTR 30 | Makefiles 31 | micdemo 32 | picovoice 33 | podfile 34 | Prefs 35 | probs 36 | pthread 37 | pvcobra 38 | pvcobrademo 39 | pvrecorder 40 | Readables 41 | repr 42 | rodio 43 | signup 44 | soundfile 45 | styleable 46 | sysdefault 47 | testapp 48 | vtable 49 | wargv 50 | wavspec 51 | xcframework 52 | xcworkspace 53 | xcodeproj 54 | xcuitest 55 | wavefile 56 | NETCOREAPP 57 | Cdecl 58 | finalizer 59 | netcoreapp 60 | netstandard 61 | framecount -------------------------------------------------------------------------------- /res/.lint/swift/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | disabled_rules: 2 | - identifier_name 3 | - function_body_length 4 | - force_cast 5 | - implicit_getter 6 | - cyclomatic_complexity 7 | - function_parameter_count 8 | excluded: 9 | - ${PWD}/**/Pods -------------------------------------------------------------------------------- /res/audio/sample.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Picovoice/cobra/77313f25eadde2f38243bed126c69f5ff602bf5b/res/audio/sample.wav -------------------------------------------------------------------------------- /res/scripts/machine-state.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -e "-------------------------------Machine State----------------------------" 4 | echo -e "CPU Usage:\t"`cat /proc/stat | awk '/cpu/{printf("%.2f%%\n"), ($2+$4)*100/($2+$4+$5)}' | awk '{print $0}' | head -1` 5 | echo -e "Memory Usage:\t"`free | awk '/Mem/{printf("%.2f%%"), $3/$2*100}'` 6 | echo -e "Swap Usage:\t"`free | awk '/Swap/{printf("%.2f%%"), $3/$2*100}'` 7 | paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | column -s $'\t' -t | sed 's/\(.\)..$/.\1°C/' 8 | --------------------------------------------------------------------------------