Coder Social home page Coder Social logo

microsoft / cognitive-speakerrecognition-android Goto Github PK

View Code? Open in Web Editor NEW
48.0 61.0 41.0 87 KB

Android SDK for Microsoft Speaker Recognition API, part of Cognitive Services

Home Page: https://www.microsoft.com/cognitive-services/en-us/speaker-recognition-api

License: Other

Java 100.00%

cognitive-speakerrecognition-android's Introduction

Microsoft Speaker Recognition API: Android Client Library

This repo contains the Android client library for the Microsoft Speaker Recognition API, an offering within Microsoft Cognitive Services, formerly known as Project Oxford.

The client library

This client library is a thin Java client wrapper for the Microsoft Speaker Recognition REST API.

The easiest way to consume the client library is to add com.microsoft.cognitive.speakerrecognition package from Maven Central Repository.

To find the latest version of client library, go to http://search.maven.org, and search for "com.microsoft.cognitive".

To add the client library dependency from build.gradle file, add the following line in dependencies.

dependencies {
    //
    // Use the following line to include client library from Maven Central Repository
    // Change the version number from the search.maven.org result
    //
    compile 'com.microsoft.cognitive:speakerrecognition:1.0.0'

    // Your other Dependencies...
}

To do add the client library dependency from Android Studio:

  1. From Menu, Choose File > Project Structure
  2. Click on your app module
  3. Click on Dependencies tab
  4. Click "+" sign to add new dependency
  5. Pick "Library dependency" from the drop down list
  6. Type "com.microsoft.cognitive" and hit the search icon from "Choose Library Dependency" dialog
  7. Pick the Cognitive Services client library that you intend to use.
  8. Click "OK" to add the new dependency

Contributing

We welcome contributions. Feel free to file issues and pull requests on the repo and we'll address them as we can. Learn more about how you can help on our Contribution Rules & Guidelines.

You can reach out to us anytime with questions and suggestions using our communities below:

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

License

All Microsoft Cognitive Services SDKs and samples are licensed with the MIT License. For more details, see LICENSE.

Sample images are licensed separately, please refer to LICENSE-IMAGE.

cognitive-speakerrecognition-android's People

Contributors

hoda-gharieb avatar m-sherif avatar msftgits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cognitive-speakerrecognition-android's Issues

A library uses the same package as this project: com.microsoft.cognitive.speakerrecognition

Trying to running this project in Android Studio.
Have added the dependency -- compile 'com.microsoft.cognitive:speakerrecognition:1.1.0'
and added the library by going to the project structure..

When I run this, I am getting the error -- ```

Error:Execution failed for task ':lib:processDebugResources'.

Error: A library uses the same package as this project: com.microsoft.cognitive.speakerrecognition

Manifest issue

I'm trying to use this in an Android app, and I am getting an error in the generated AndroidManifest.xml. I see this hasn't been updated since 2018. Has anyone seen this issue or knows how to fix it? Thanks!

(Generated)AndroidManifest/xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.microsoft.cognitive.speakerrecognition" >

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="23" />

    <uses-permission android:name="android.permission.INTERNET" />

    <library />

</manifest>

Error:

Android resource linking failed
Users/name/.gradle/caches/transforms-2/files-2.1/c2711902cf53262afeb76732b9f5f020/jetified-speakerrecognition-1.1.0/AndroidManifest.xml:11:5-16: AAPT: error: unexpected element <library> found in <manifest>.

Languages supported?

I want to create a speaker identification android app. But in Hungarian language. Can I use this for that?

Speaker invalid: 500 internal server error

I am trying to enroll for speaker recognition. I am unable to do it. I am getting a 500 internal error-invalid speaker response. I checked the audio file and It seems to be clear and the phrase is one from the list given. Is it possible that the server is not recognizing the phrase due to different accent? I have attached the audio file here.
phrase.wav.zip

Error importing the library in Android Studio

Hi,

I tried importing the library in my Android Studio with both methods - AAR importing and Gradle dependency. But I am getting the following error while gradle building -

`Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
D:\VivekData\Android\work\voice authenticator\app\build\intermediates\manifests\full\debug\AndroidManifest.xml
Error:(15) error: unknown element found.
Error:(15) unknown element found.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.

Failed to execute aapt
Information:BUILD FAILED in 25s
Information:6 errors
Information:0 warnings
Information:See complete output in console`

It shows in the build manifest that a library tag is added which I cant edit. Please suggest what to do thanks!!

message: Access denied due to invalid subscription key.

Hi I am having same issue when I called the function "identify(InputStream audioStream, List ids, boolean forceShortAudio)".

{"error":{"code":"Unspecified","message":"Access denied due to invalid subscription key. Make sure you are subscribed to an API you are trying to call and provide the right key."}}

But it is ok When I was using "Cognitive-SpeakerRecognition-Python" with the same key.

Invalid Audio Format: Not a WAVE file - no RIFF header

I am developing an application and I record the user's speech using the phone's microphones, save the recording in a 16 bit PCM encoded .wav file ... just as the documentation says. However when sending to the API I get the following response: {"error": {"code": "BadRequest", "message": "Invalid Audio Format: Not a WAVE file - no RIFF header"}}. I tried setting the header RIFF but was unsuccessful, could anyone help me?

Unable to enrol an user

Hi ,
I am trying to enrol an user and I am getting 400 Bad request. Please find the detail error below.

Can't figure out what I am doing wrong.

Thank you!
{
"error": {
"code": "BadRequest",
"message": "SpeakerInvalid"
}
}

The wave file I am using is
test.zip

"message": "Invalid Audio Format: Not a WAVE file - no RIFF header"

Hi I am having same issue.
I have recorded audio file and converted to .wav using online tool. as there was not a single example showing to record file in correct format.
But its giving same error
VishwasVoice (2).zip

"message": "Invalid Audio Format: Not a WAVE file - no RIFF header"
please find attached audio file.
Also please provide example to convert audio file into specified format or direct streaming options through android.

Lint error: Duplicate platform classes

The Apache HTTP client applied is duplicating Android OS implementation classes, see below error.

I propose moving to OkHttp instead...

--- Lint output ---

<path>/app: Error: commons-logging defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]
<path>/app: Error: httpclient defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]

   Explanation for issues of type "DuplicatePlatformClasses":
   There are a number of libraries that duplicate not just functionality of
   the Android platform but using the exact same class names as the ones
   provided in Android -- for example the apache http classes. This can lead
   to unexpected crashes.

   To solve this, you need to either find a newer version of the library which
   no longer has this problem, or to repackage the library (and all of its
   dependencies) using something like the jarjar tool, or finally, rewriting
   the code to use different APIs (for example, for http code, consider using
   HttpUrlConnection or a library like okhttp).

Accuracy Issue in Identification in Speaker Recognition

The API always returns a profile id whether there happens a match or not.
Eg If I have enrolled 5 persons and I send the sample of 6th person(not among the 5 enrolled), the API will still return an Id from those 5 Profile ids

I am using the Java sample code. Please tell if I am doing something wrong or is there a bug in the API.

Cannot retrieve verification phrases

I started to test this library for android adding it as dependency in the build.gradle file but I get an error on the getPhrases function.

Here is my code:

private void retrieveSupportedPhrases() {
        SpeakerVerificationRestClient restClient = new SpeakerVerificationRestClient(MY_KEY);
        try {
            List<VerificationPhrase> phrases = restClient.getPhrases("en-US");
            for (int i = 0; i < phrases.size(); i++) {
                Log.i(TAG, phrases.get(i).toString());
            }
        } catch (PhrasesException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }

Here is the error:

FATAL EXCEPTION: main
Process: com.mobile.cir.voicerecognition, PID: 1709
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mobile.cir.voicerecognition/com.mobile.cir.voicerecognition.activity.EnableVoiceRecognition}: android.os.NetworkOnMainThreadException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
at java.net.InetAddress.lookupHostByName(InetAddress.java:431)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
at java.net.InetAddress.getAllByName(InetAddress.java:215)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:142)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:169)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:124)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:366)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:560)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:492)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:470)
at com.microsoft.cognitive.speakerrecognition.SpeakerVerificationRestClient.getPhrases(SpeakerVerificationRestClient.java:265)
at com.mobile.cir.voicerecognition.activity.EnableVoiceRecognition.retrieveSupportedPhrases(EnableVoiceRecognition.java:85)
at com.mobile.cir.voicerecognition.activity.EnableVoiceRecognition.onCreate(EnableVoiceRecognition.java:77)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I am trying to encroll an audio file but return BadRequest

Here is my code.

SpeakerVerificationRestClient speakerVerificationRestClient = new SpeakerVerificationRestClient(MY_KEY); try { File file = new File(MY_FILE_PATH); FileInputStream fileInputStream = new FileInputStream(file); Enrollment enrollment = speakerVerificationRestClient.enroll(fileInputStream, UUID); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (EnrollmentException e) { e.printStackTrace(); } } });

It's return
{ "error": { "code": "BadRequest", "message": "SpeechNotRecognized" }}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.