Add the client library
This commit is contained in:
Родитель
84f02fd507
Коммит
e58f90ad65
|
@ -0,0 +1,18 @@
|
|||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
out/
|
||||
build/
|
||||
|
||||
# OS specific files
|
||||
.DS_Store
|
||||
|
||||
# IntelliJ / Android studio configuration files
|
||||
.idea/
|
||||
*.iml
|
||||
|
||||
# Gradle generated files
|
||||
.gradle/
|
||||
|
||||
# Local config (e.g. sdk path)
|
||||
local.properties
|
|
@ -0,0 +1,8 @@
|
|||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
*.iml
|
||||
/captures
|
|
@ -0,0 +1,16 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.1.0'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
|
||||
signing.keyId=
|
||||
signing.password=
|
||||
signing.secretKeyRingFile=
|
||||
|
||||
ossrhUsername=
|
||||
ossrhPassword=
|
||||
|
Двоичный файл не отображается.
|
@ -0,0 +1,6 @@
|
|||
#Mon Apr 18 18:13:36 EET 2016
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
|
|
@ -0,0 +1,164 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
|
@ -0,0 +1,90 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -0,0 +1 @@
|
|||
/build
|
|
@ -0,0 +1,22 @@
|
|||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion '23.0.3'
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 23
|
||||
}
|
||||
|
||||
// HttpClient is not supported in Android SDK 23
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.google.code.gson:gson:2.4'
|
||||
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
|
||||
compile('org.apache.httpcomponents:httpmime:4.3') {
|
||||
exclude module: "httpclient"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.microsoft.cognitive.speakerrecognition" >
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<library></library>
|
||||
</manifest>
|
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition;
|
||||
|
||||
/**
|
||||
* An object encapsulating an error message
|
||||
*/
|
||||
class ErrorMessage {
|
||||
|
||||
/**
|
||||
* A string representation of the error code
|
||||
*/
|
||||
public String code;
|
||||
|
||||
/**
|
||||
* A string representation of the error message
|
||||
*/
|
||||
public String message;
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition;
|
||||
|
||||
/**
|
||||
* A class encapsulating the error response
|
||||
*/
|
||||
class ErrorResponse {
|
||||
/**
|
||||
* ErrorResponse object encapsulating details about the error
|
||||
*/
|
||||
public ErrorMessage error;
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition;
|
||||
|
||||
/**
|
||||
* An enum representing the different HTTP request methods used in this class
|
||||
*/
|
||||
enum RequestType {
|
||||
|
||||
/**
|
||||
* HTTP post request
|
||||
*/
|
||||
POST,
|
||||
|
||||
/**
|
||||
* HTTP get request
|
||||
*/
|
||||
GET,
|
||||
|
||||
/**
|
||||
* HTTP delete request
|
||||
*/
|
||||
DELETE
|
||||
};
|
|
@ -0,0 +1,146 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition;
|
||||
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.CreateProfileException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.DeleteProfileException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.EnrollmentException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.GetProfileException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.ResetEnrollmentsException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.identification.CreateProfileResponse;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.identification.EnrollmentOperation;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.identification.IdentificationException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.identification.IdentificationOperation;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.identification.OperationLocation;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.identification.Profile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* An interface for a speaker identification service client related methods
|
||||
*/
|
||||
public interface SpeakerIdentificationClient {
|
||||
|
||||
/**
|
||||
* Identifies a given speaker using the speaker ID and audio stream
|
||||
*
|
||||
* @param audioStream The audio stream to identify
|
||||
* @param ids The list of possible speaker profile IDs to identify from
|
||||
* @return An object encapsulating the Url that can be used to query the identification operation status
|
||||
* @throws IdentificationException Thrown in case of an internal server error, invalid IDs or a wrong audio format
|
||||
* @throws IOException Signals an I/O issue while reading the audio stream, a connection abortion, or an invalid response content
|
||||
*/
|
||||
OperationLocation identify(InputStream audioStream, List<UUID> ids) throws IdentificationException, IOException;
|
||||
|
||||
/**
|
||||
* Creates a new speaker profile
|
||||
*
|
||||
* @param locale The speaker profile locale
|
||||
* @return The profile object encapsulating the response object of the create request
|
||||
* @throws CreateProfileException Thrown on cases of internal server error or an invalid locale
|
||||
* @throws IOException Signals an invalid locale encoding, a connection abortion, or an invalid response content
|
||||
*/
|
||||
CreateProfileResponse createProfile(String locale) throws CreateProfileException, IOException;
|
||||
|
||||
/**
|
||||
* Deletes a given speaker profile
|
||||
*
|
||||
* @param id The ID of the speaker profile to be deleted
|
||||
* @throws DeleteProfileException Thrown on case of an internal server error or an invalid ID
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
void deleteProfile(UUID id) throws DeleteProfileException, IOException;
|
||||
|
||||
/**
|
||||
* Retrieves a speaker profile from the service
|
||||
*
|
||||
* @param id The ID of the speaker profile to get
|
||||
* @return The requested profile
|
||||
* @throws GetProfileException Thrown in cases of invalid ID or an internal server error
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
Profile getProfile(UUID id) throws GetProfileException, IOException;
|
||||
|
||||
/**
|
||||
* Gets all speaker profiles from the service
|
||||
*
|
||||
* @return An array containing a list of all profiles
|
||||
* @throws GetProfileException Thrown in case of an internal server error
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
List<Profile> getProfiles() throws GetProfileException, IOException;
|
||||
|
||||
/**
|
||||
* Enrolls a speaker profile from an audio stream
|
||||
*
|
||||
* @param audioStream The audio stream to use for enrollment
|
||||
* @param id The speaker profile ID to enroll
|
||||
* @return An object encapsulating the Url that can be used to query the enrollment operation status
|
||||
* @throws EnrollmentException Thrown in case of an invalid audio format, internal server error or an invalid ID
|
||||
* @throws IOException Signals an I/O issue while reading the audio stream, a connection abortion, or an invalid response content
|
||||
*/
|
||||
OperationLocation enroll(InputStream audioStream, UUID id) throws EnrollmentException, IOException;
|
||||
|
||||
/**
|
||||
* Gets the enrollment operation status or result
|
||||
*
|
||||
* @param location The Url returned upon calling the enrollment operation
|
||||
* @return The enrollment operation object encapsulating the result
|
||||
* @throws EnrollmentException Thrown in case of an internal server error or an invalid URL
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
EnrollmentOperation checkEnrollmentStatus(OperationLocation location) throws EnrollmentException, IOException;
|
||||
|
||||
/**
|
||||
* Gets the identification operation status or result
|
||||
*
|
||||
* @param location The Url returned upon calling the identification operation
|
||||
* @return The identification operation object encapsulating the result
|
||||
* @throws IdentificationException Thrown in case of an internal server error or a wrong URL
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
IdentificationOperation checkIdentificationStatus(OperationLocation location) throws IdentificationException, IOException;
|
||||
|
||||
/**
|
||||
* Deletes all enrollments associated with the given speaker identification profile permanently from the service
|
||||
*
|
||||
* @param id The speaker ID
|
||||
* @throws ResetEnrollmentsException Thrown in case of internal server error or an invalid ID
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
void resetEnrollments(UUID id) throws ResetEnrollmentsException, IOException;
|
||||
}
|
|
@ -0,0 +1,420 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition;
|
||||
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.CreateProfileException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.DeleteProfileException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.EnrollmentException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.GetProfileException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.ResetEnrollmentsException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.identification.CreateProfileResponse;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.identification.EnrollmentOperation;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.identification.IdentificationException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.identification.IdentificationOperation;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.identification.OperationLocation;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.identification.Profile;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpDelete;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
/**
|
||||
* This class abstracts all the identification service calls
|
||||
*/
|
||||
public class SpeakerIdentificationRestClient implements SpeakerIdentificationClient {
|
||||
|
||||
/**
|
||||
* The Http client used to communicate with the service
|
||||
*/
|
||||
private HttpClient defaultHttpClient;
|
||||
|
||||
/**
|
||||
* Address of the identification profiles API
|
||||
*/
|
||||
private static final String IDENTIFICATION_PROFILE_URI = "https://api.projectoxford.ai/spid/v1.0/identificationProfiles";
|
||||
|
||||
/**
|
||||
* Address of the identification API
|
||||
*/
|
||||
private static final String IDENTIFICATION_URI = "https://api.projectoxford.ai/spid/v1.0/identify";
|
||||
|
||||
/**
|
||||
* The operation location header field
|
||||
*/
|
||||
private static final String _OPERATION_LOCATION_HEADER = "Operation-Location";
|
||||
|
||||
/**
|
||||
* Json Serializer / deserializer
|
||||
*/
|
||||
private Gson gson;
|
||||
|
||||
/**
|
||||
* The locale parameter
|
||||
*/
|
||||
private static final String LOCALE_PARAM = "locale";
|
||||
|
||||
/**
|
||||
* Speaker client clientHelper
|
||||
*/
|
||||
private SpeakerRestClientHelper clientHelper;
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Initializes an instance of the service client
|
||||
*
|
||||
* @param subscriptionKey The subscription key to use
|
||||
*/
|
||||
public SpeakerIdentificationRestClient(String subscriptionKey) {
|
||||
defaultHttpClient = new DefaultHttpClient();
|
||||
gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:SS.SSS").create();
|
||||
clientHelper = new SpeakerRestClientHelper(subscriptionKey);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a new speaker profile
|
||||
*
|
||||
* @param locale The speaker profile locale
|
||||
* @return The profile object encapsulating the response object of the create request
|
||||
* @throws CreateProfileException Thrown on cases of internal server error or an invalid locale
|
||||
* @throws IOException Signals an invalid locale encoding, a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public CreateProfileResponse createProfile(String locale) throws CreateProfileException, IOException {
|
||||
|
||||
HttpPost request = (HttpPost) clientHelper.createHttpRequest(IDENTIFICATION_PROFILE_URI, RequestType.POST);
|
||||
|
||||
List<NameValuePair> paramsList = new ArrayList<>();
|
||||
paramsList.add(new BasicNameValuePair(LOCALE_PARAM, locale));
|
||||
request.setEntity(new UrlEncodedFormEntity(paramsList));
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_OK) {
|
||||
return gson.fromJson(stringResponse, CreateProfileResponse.class);
|
||||
} else {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new CreateProfileException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new CreateProfileException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a speaker profile from the service
|
||||
*
|
||||
* @param id The ID of the speaker profile to get
|
||||
* @return The requested profile
|
||||
* @throws GetProfileException Thrown in cases of invalid ID or an internal server error
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public Profile getProfile(UUID id) throws GetProfileException, IOException {
|
||||
|
||||
HttpGet request = (HttpGet) clientHelper.createHttpRequest(IDENTIFICATION_PROFILE_URI + "/" + id.toString(), RequestType.GET);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_OK) {
|
||||
return gson.fromJson(stringResponse, Profile.class);
|
||||
} else {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new GetProfileException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new GetProfileException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all speaker profiles from the service
|
||||
*
|
||||
* @return An array containing a list of all profiles
|
||||
* @throws GetProfileException Thrown in case of an internal server error
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public List<Profile> getProfiles() throws GetProfileException, IOException {
|
||||
|
||||
HttpGet request = (HttpGet) clientHelper.createHttpRequest(IDENTIFICATION_PROFILE_URI, RequestType.GET);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_OK) {
|
||||
Type listType = new TypeToken<List<Profile>>(){}.getType();
|
||||
return gson.fromJson(stringResponse, listType);
|
||||
} else {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new GetProfileException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new GetProfileException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a given speaker profile
|
||||
*
|
||||
* @param id The ID of the speaker profile to be deleted
|
||||
* @throws DeleteProfileException Thrown on case of an internal server error or an invalid ID
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public void deleteProfile(UUID id) throws DeleteProfileException, IOException {
|
||||
|
||||
HttpDelete request = (HttpDelete) clientHelper.createHttpRequest(IDENTIFICATION_PROFILE_URI + "/" + id.toString(), RequestType.DELETE);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode != HttpStatus.SC_OK) {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new DeleteProfileException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new DeleteProfileException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enrolls a speaker profile from an audio stream
|
||||
*
|
||||
* @param audioStream The audio stream to use for enrollment
|
||||
* @param id The speaker profile ID to enroll
|
||||
* @return An object encapsulating the Url that can be used to query the enrollment operation status
|
||||
* @throws EnrollmentException Thrown in case of an invalid audio format, internal server error or an invalid ID
|
||||
* @throws IOException Signals an I/O issue while reading the audio stream, a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public OperationLocation enroll(InputStream audioStream, UUID id) throws EnrollmentException, IOException {
|
||||
|
||||
String requestUrl = IDENTIFICATION_PROFILE_URI + "/" + id.toString() + "/enroll";
|
||||
HttpPost request = (HttpPost) clientHelper.createHttpRequest(requestUrl, RequestType.POST);
|
||||
|
||||
String fileName = id.toString() + "_" + new Date();
|
||||
HttpEntity entity = clientHelper.addStreamToEntity(audioStream, "enrollmentData", fileName);
|
||||
request.setEntity(entity);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_ACCEPTED) { // 202 Accepted (HTTP/1.0 - RFC 1945)
|
||||
String header = response.getFirstHeader(_OPERATION_LOCATION_HEADER).getValue();
|
||||
if (header.trim().length() != 0) {
|
||||
OperationLocation opLoc = new OperationLocation();
|
||||
opLoc.Url = header;
|
||||
return opLoc;
|
||||
} else {
|
||||
throw new EnrollmentException("Incorrect server response");
|
||||
}
|
||||
} else {
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new EnrollmentException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new EnrollmentException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the enrollment operation status or result
|
||||
*
|
||||
* @param location The Url returned upon calling the enrollment operation
|
||||
* @return The enrollment operation object encapsulating the result
|
||||
* @throws EnrollmentException Thrown in case of an internal server error or an invalid URL
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public EnrollmentOperation checkEnrollmentStatus(OperationLocation location) throws EnrollmentException, IOException {
|
||||
|
||||
HttpGet request = (HttpGet) clientHelper.createHttpRequest(location.Url, RequestType.GET);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_OK) {
|
||||
return gson.fromJson(stringResponse, EnrollmentOperation.class);
|
||||
} else {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new EnrollmentException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new EnrollmentException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all enrollments associated with the given speaker identification profile permanently from the service
|
||||
*
|
||||
* @param id The speaker ID
|
||||
* @throws ResetEnrollmentsException Thrown in case of internal server error or an invalid ID
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public void resetEnrollments(UUID id) throws ResetEnrollmentsException, IOException {
|
||||
|
||||
String requestUrl = IDENTIFICATION_PROFILE_URI + "/" + id.toString() + "/reset";
|
||||
HttpPost request = (HttpPost) clientHelper.createHttpRequest(requestUrl, RequestType.POST);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode != HttpStatus.SC_OK) {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new ResetEnrollmentsException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new ResetEnrollmentsException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the identification operation status or result
|
||||
*
|
||||
* @param location The Url returned upon calling the identification operation
|
||||
* @return The identification operation object encapsulating the result
|
||||
* @throws IdentificationException Thrown in case of an internal server error or a wrong URL
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public IdentificationOperation checkIdentificationStatus(OperationLocation location) throws IdentificationException, IOException {
|
||||
|
||||
HttpGet request = (HttpGet) clientHelper.createHttpRequest(location.Url, RequestType.GET);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_OK) {
|
||||
return gson.fromJson(stringResponse, IdentificationOperation.class);
|
||||
} else {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new IdentificationException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new IdentificationException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifies a given speaker using the speaker ID and audio stream
|
||||
*
|
||||
* @param audioStream The audio stream to identify
|
||||
* @param ids The list of possible speaker profile IDs to identify from
|
||||
* @return An object encapsulating the Url that can be used to query the identification operation status
|
||||
* @throws IdentificationException Thrown in case of an internal server error, invalid IDs or a wrong audio format
|
||||
* @throws IOException Signals an I/O issue while reading the audio stream, a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public OperationLocation identify(InputStream audioStream, List<UUID> ids) throws IdentificationException, IOException {
|
||||
|
||||
String testProfileIds = clientHelper.buildProfileIdsString(ids);
|
||||
String requestUrl = IDENTIFICATION_URI + "?identificationProfileIds=" + testProfileIds.toString();
|
||||
HttpPost request = (HttpPost) clientHelper.createHttpRequest(requestUrl, RequestType.POST);
|
||||
|
||||
String fileName = "identificationsIds" + "_" + new Date();
|
||||
HttpEntity entity = clientHelper.addStreamToEntity(audioStream, "identificationData", fileName);
|
||||
request.setEntity(entity);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_ACCEPTED) { // 202 Accepted (HTTP/1.0 - RFC 1945)
|
||||
String header = response.getFirstHeader(_OPERATION_LOCATION_HEADER).getValue();
|
||||
if (header.trim().length() != 0) {
|
||||
OperationLocation opLoc = new OperationLocation();
|
||||
opLoc.Url = header;
|
||||
return opLoc;
|
||||
} else {
|
||||
throw new IdentificationException("Incorrect server response");
|
||||
}
|
||||
} else {
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new IdentificationException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new IdentificationException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpDelete;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.mime.HttpMultipartMode;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
|
||||
/**
|
||||
* A package-private helper class
|
||||
*/
|
||||
class SpeakerRestClientHelper {
|
||||
|
||||
/**
|
||||
* The header for the subscription key
|
||||
*/
|
||||
private static final String OCP_SUBSCRIPTION_KEY_HEADER = "Ocp-Apim-Subscription-Key";
|
||||
|
||||
/**
|
||||
* Json accept header
|
||||
*/
|
||||
private static final String JSON_HEADER_ACCEPT = "accept";
|
||||
|
||||
/**
|
||||
* Json accept header value
|
||||
*/
|
||||
private static final String JSON_HEADER_VALUE_ACCEPT = "application/json";
|
||||
|
||||
/**
|
||||
* Subscription key
|
||||
*/
|
||||
private String subscriptionKey;
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
|
||||
SpeakerRestClientHelper(String subscriptionKey) {
|
||||
this.subscriptionKey = subscriptionKey;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Retrieves the status code of an HTTP response
|
||||
*
|
||||
* @param response HTTP response
|
||||
* @return HTTP status code
|
||||
*/
|
||||
int getStatusCode(HttpResponse response) {
|
||||
return response.getStatusLine().getStatusCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTTP request
|
||||
*
|
||||
* @param resourceURL HTTP resource address
|
||||
* @param requestType HTTP request type
|
||||
* @return HTTP request
|
||||
*/
|
||||
HttpUriRequest createHttpRequest(String resourceURL, RequestType requestType) {
|
||||
HttpUriRequest request;
|
||||
|
||||
switch (requestType) {
|
||||
case GET:
|
||||
request = new HttpGet(resourceURL);
|
||||
break;
|
||||
case POST:
|
||||
request = new HttpPost(resourceURL);
|
||||
break;
|
||||
case DELETE:
|
||||
request = new HttpDelete(resourceURL);
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
request.addHeader(JSON_HEADER_ACCEPT, JSON_HEADER_VALUE_ACCEPT);
|
||||
request.addHeader(OCP_SUBSCRIPTION_KEY_HEADER, subscriptionKey);
|
||||
return request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an HTTP response to a string
|
||||
*
|
||||
* @param response HTTP response
|
||||
* @return A string representation of the HTTP response
|
||||
* @throws IOException Signals that a content stream couldn't be created from the HTTP response entity
|
||||
*/
|
||||
String httpResponseToString(HttpResponse response) throws IOException {
|
||||
InputStream responseStream = response.getEntity().getContent();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(responseStream));
|
||||
String str;
|
||||
StringBuilder stringResponse = new StringBuilder();
|
||||
while ((str = reader.readLine()) != null) {
|
||||
stringResponse.append(str);
|
||||
}
|
||||
return stringResponse.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a stream to an HTTP entity
|
||||
*
|
||||
* @param someStream Input stream to be added to an HTTP entity
|
||||
* @param fieldName A description of the entity content
|
||||
* @param fileName Name of the file attached as an entity
|
||||
* @return HTTP entity
|
||||
* @throws IOException Signals a failure while reading the input stream
|
||||
*/
|
||||
HttpEntity addStreamToEntity(InputStream someStream, String fieldName, String fileName) throws IOException {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
int bytesRead;
|
||||
byte[] bytes = new byte[1024];
|
||||
while ((bytesRead = someStream.read(bytes)) > 0) {
|
||||
byteArrayOutputStream.write(bytes, 0, bytesRead);
|
||||
}
|
||||
byte[] data = byteArrayOutputStream.toByteArray();
|
||||
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
||||
builder.setStrictMode();
|
||||
builder.addBinaryBody(fieldName, data, ContentType.MULTIPART_FORM_DATA, fileName);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a list of profile IDs to a single string
|
||||
*
|
||||
* @param ids List of profile IDs
|
||||
* @return String of profile IDs separated by a comma(",")
|
||||
*/
|
||||
String buildProfileIdsString(List<UUID> ids) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Iterator<?> iter = ids.iterator();
|
||||
while (iter.hasNext()) {
|
||||
builder.append(iter.next());
|
||||
if (!iter.hasNext()) {
|
||||
break;
|
||||
}
|
||||
builder.append(",");
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition;
|
||||
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.CreateProfileException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.DeleteProfileException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.EnrollmentException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.GetProfileException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.ResetEnrollmentsException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.CreateProfileResponse;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.Enrollment;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.PhrasesException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.Profile;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.Verification;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.VerificationException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.VerificationPhrase;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* An interface for the speaker verification service client related methods
|
||||
*/
|
||||
public interface SpeakerVerificationClient {
|
||||
|
||||
/**
|
||||
* Creates a new speaker profile
|
||||
*
|
||||
* @param locale The speaker profile locale
|
||||
* @return The Profile object encapsulating the speaker profile response
|
||||
* @throws CreateProfileException Thrown in case of internal server error or an invalid locale
|
||||
* @throws IOException Signals an invalid locale encoding, a connection abortion, or an invalid response content
|
||||
*/
|
||||
CreateProfileResponse createProfile(String locale) throws CreateProfileException, IOException;
|
||||
|
||||
/**
|
||||
* Retrieves a given speaker profile as specified by the id parameter
|
||||
*
|
||||
* @param id The speaker profile ID
|
||||
* @return The requested speaker profile
|
||||
* @throws GetProfileException Thrown in case of internal server error or an invalid ID
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
Profile getProfile(UUID id) throws GetProfileException, IOException;
|
||||
|
||||
/**
|
||||
* Retrieves all available speaker profiles
|
||||
*
|
||||
* @return A list of speaker profiles
|
||||
* @throws GetProfileException Thrown in case of internal server error or an invalid ID
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
List<Profile> getProfiles() throws GetProfileException, IOException;
|
||||
|
||||
/**
|
||||
* Deletes a given speaker profile
|
||||
*
|
||||
* @param id The ID of the speaker profile to be deleted
|
||||
* @throws DeleteProfileException Thrown in case of internal server error, an invalid ID or failure to delete the profile
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
void deleteProfile(UUID id) throws DeleteProfileException, IOException;
|
||||
|
||||
/**
|
||||
* Gets a list of all available phrases for enrollments
|
||||
*
|
||||
* @param locale The locale of the phrases
|
||||
* @return A list of all verification phrases
|
||||
* @throws PhrasesException Thrown in case of invalid locale or internal server error
|
||||
* @throws IOException Signals an invalid locale encoding, a connection abortion, or an invalid response content
|
||||
* @throws URISyntaxException Signals that the endpoint string could not be parsed as a URI reference
|
||||
*/
|
||||
List<VerificationPhrase> getPhrases(String locale) throws PhrasesException, IOException, URISyntaxException;
|
||||
|
||||
/**
|
||||
* Enrolls a new stream for a given speaker
|
||||
*
|
||||
* @param audioStream The stream to enroll
|
||||
* @param id The speaker profile speaker ID
|
||||
* @return Enrollment object encapsulating the enrollment response
|
||||
* @throws EnrollmentException Thrown in case of internal server error, wrong ID or an invalid audio format
|
||||
* @throws IOException Signals an I/O issue while reading the audio stream, a connection abortion, or an invalid response content
|
||||
*/
|
||||
Enrollment enroll(InputStream audioStream, UUID id) throws EnrollmentException, IOException;
|
||||
|
||||
/**
|
||||
* Verifies a given speaker using the speaker ID and audio stream
|
||||
*
|
||||
* @param audioStream The stream of audio to be verified
|
||||
* @param id The speaker ID
|
||||
* @return A verification object encapsulating the verification result
|
||||
* @throws VerificationException Thrown in case of invalid ID, invalid audio format or internal server error
|
||||
* @throws IOException Signals an I/O issue while reading the audio stream, a connection abortion, or an invalid response content
|
||||
*/
|
||||
Verification verify(InputStream audioStream, UUID id) throws VerificationException, IOException;
|
||||
|
||||
/**
|
||||
* Deletes all enrollments associated with the given speaker verification profile permanently from the service
|
||||
*
|
||||
* @param id The speaker ID
|
||||
* @throws ResetEnrollmentsException Thrown in case of invalid ID, failure to reset the profile or an internal server error
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
void resetEnrollments(UUID id) throws ResetEnrollmentsException, IOException;
|
||||
}
|
|
@ -0,0 +1,382 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition;
|
||||
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.CreateProfileException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.DeleteProfileException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.EnrollmentException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.GetProfileException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.ResetEnrollmentsException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.CreateProfileResponse;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.Enrollment;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.PhrasesException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.Profile;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.Verification;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.VerificationException;
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.verification.VerificationPhrase;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpDelete;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
/**
|
||||
* A service client class to perform all the verification service calls
|
||||
*/
|
||||
public class SpeakerVerificationRestClient implements SpeakerVerificationClient {
|
||||
|
||||
/**
|
||||
* Address of the verification profiles API
|
||||
*/
|
||||
private static final String BASE_URI = "https://api.projectoxford.ai/spid/v1.0/verificationProfiles";
|
||||
|
||||
/**
|
||||
* Address of the verification API
|
||||
*/
|
||||
private static final String VERIFY_ENDPOINT = "https://api.projectoxford.ai/spid/v1.0/verify";
|
||||
|
||||
/**
|
||||
* Address of the verification phrases API
|
||||
*/
|
||||
private static final String PHRASES_ENDPOINT = "https://api.projectoxford.ai/spid/v1.0/verificationPhrases?locale=";
|
||||
|
||||
/**
|
||||
* The locale parameter
|
||||
*/
|
||||
private static final String LOCALE_PARAM = "locale";
|
||||
|
||||
/**
|
||||
* The Http client used to communicate with the service
|
||||
*/
|
||||
private HttpClient defaultHttpClient;
|
||||
|
||||
/**
|
||||
* Json Serializer / deserializer
|
||||
*/
|
||||
private Gson gson;
|
||||
|
||||
/**
|
||||
* Speaker client clientHelper
|
||||
*/
|
||||
private SpeakerRestClientHelper clientHelper;
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a new service client using a subscription key
|
||||
*
|
||||
* @param subscriptionKey The subscription key
|
||||
*/
|
||||
public SpeakerVerificationRestClient(String subscriptionKey) {
|
||||
defaultHttpClient = new DefaultHttpClient();
|
||||
gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:SS.SSS").create();
|
||||
clientHelper = new SpeakerRestClientHelper(subscriptionKey);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a new speaker profile
|
||||
*
|
||||
* @param locale The speaker profile locale
|
||||
* @return The Profile object encapsulating the speaker profile response
|
||||
* @throws CreateProfileException Thrown in case of internal server error or an invalid locale
|
||||
* @throws IOException Signals an invalid locale encoding, a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public CreateProfileResponse createProfile(String locale) throws CreateProfileException, IOException {
|
||||
|
||||
HttpPost request = (HttpPost) clientHelper.createHttpRequest(BASE_URI, RequestType.POST);
|
||||
|
||||
List<NameValuePair> paramsList = new ArrayList<>();
|
||||
paramsList.add(new BasicNameValuePair(LOCALE_PARAM, locale));
|
||||
request.setEntity(new UrlEncodedFormEntity(paramsList));
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_OK) {
|
||||
return gson.fromJson(stringResponse, CreateProfileResponse.class);
|
||||
} else {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new CreateProfileException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new CreateProfileException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a given speaker profile as specified by the id parameter
|
||||
*
|
||||
* @param id The speaker profile ID
|
||||
* @return The requested speaker profile
|
||||
* @throws GetProfileException Thrown in case of internal server error or an invalid ID
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public Profile getProfile(UUID id) throws GetProfileException, IOException {
|
||||
|
||||
HttpGet request = (HttpGet) clientHelper.createHttpRequest(BASE_URI + "/" + id.toString(), RequestType.GET);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_OK) {
|
||||
return gson.fromJson(stringResponse, Profile.class);
|
||||
} else {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new GetProfileException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new GetProfileException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all available speaker profiles
|
||||
*
|
||||
* @return A list of speaker profiles
|
||||
* @throws GetProfileException Thrown in case of internal server error or an invalid ID
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public List<Profile> getProfiles() throws GetProfileException, IOException {
|
||||
|
||||
HttpGet request = (HttpGet) clientHelper.createHttpRequest(BASE_URI, RequestType.GET);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_OK) {
|
||||
Type listType = new TypeToken<List<Profile>>() {}.getType();
|
||||
return gson.fromJson(stringResponse, listType);
|
||||
} else {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new GetProfileException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new GetProfileException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a given speaker profile
|
||||
*
|
||||
* @param id The ID of the speaker profile to be deleted
|
||||
* @throws DeleteProfileException Thrown in case of internal server error, an invalid ID or failure to delete the profile
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public void deleteProfile(UUID id) throws DeleteProfileException, IOException {
|
||||
|
||||
HttpDelete request = (HttpDelete) clientHelper.createHttpRequest(BASE_URI + "/" + id.toString(), RequestType.DELETE);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode != HttpStatus.SC_OK) {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new DeleteProfileException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new DeleteProfileException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all available phrases for enrollments
|
||||
*
|
||||
* @param locale The locale of the phrases
|
||||
* @return A list of all verification phrases
|
||||
* @throws PhrasesException Thrown in case of invalid locale or internal server error
|
||||
* @throws IOException Signals an invalid locale encoding, a connection abortion, or an invalid response content
|
||||
* @throws URISyntaxException Signals that the endpoint string could not be parsed as a URI reference
|
||||
*/
|
||||
@Override
|
||||
public List<VerificationPhrase> getPhrases(String locale) throws PhrasesException, IOException, URISyntaxException {
|
||||
|
||||
URL url = new URL(PHRASES_ENDPOINT + locale);
|
||||
String requestURI = url.toURI().toString();
|
||||
HttpGet request = (HttpGet) clientHelper.createHttpRequest(requestURI, RequestType.GET);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_OK) {
|
||||
Type listType = new TypeToken<List<VerificationPhrase>>() {}.getType();
|
||||
return gson.fromJson(stringResponse, listType);
|
||||
} else {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new PhrasesException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new PhrasesException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enrolls a new stream for a given speaker
|
||||
*
|
||||
* @param audioStream The stream to enroll
|
||||
* @param id The speaker profile speaker ID
|
||||
* @return Enrollment object encapsulating the enrollment response
|
||||
* @throws EnrollmentException Thrown in case of internal server error, wrong ID or an invalid audio format
|
||||
* @throws IOException Signals an I/O issue while reading the audio stream, a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public Enrollment enroll(InputStream audioStream, UUID id) throws EnrollmentException, IOException {
|
||||
|
||||
String requestUrl = BASE_URI + "/" + id.toString() + "/enroll";
|
||||
HttpPost request = (HttpPost) clientHelper.createHttpRequest(requestUrl, RequestType.POST);
|
||||
|
||||
String fileName = id.toString() + "_" + new Date();
|
||||
HttpEntity entity = clientHelper.addStreamToEntity(audioStream, "enrollmentData", fileName);
|
||||
request.setEntity(entity);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_OK) {
|
||||
return gson.fromJson(stringResponse, Enrollment.class);
|
||||
} else {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new EnrollmentException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new EnrollmentException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies a given speaker using the speaker ID and audio stream
|
||||
*
|
||||
* @param audioStream The stream of audio to be verified
|
||||
* @param id The speaker ID
|
||||
* @return A verification object encapsulating the verification result
|
||||
* @throws VerificationException Thrown in case of invalid ID, invalid audio format or internal server error
|
||||
* @throws IOException Signals an I/O issue while reading the audio stream, a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public Verification verify(InputStream audioStream, UUID id) throws VerificationException, IOException {
|
||||
|
||||
String requestUrl = VERIFY_ENDPOINT + "?verificationProfileId=" + id.toString();
|
||||
HttpPost request = (HttpPost) clientHelper.createHttpRequest(requestUrl, RequestType.POST);
|
||||
|
||||
String fileName = id.toString() + "_" + new Date();
|
||||
HttpEntity entity = clientHelper.addStreamToEntity(audioStream, "verificationData", fileName);
|
||||
request.setEntity(entity);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode == HttpStatus.SC_OK) {
|
||||
return gson.fromJson(stringResponse, Verification.class);
|
||||
} else {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new VerificationException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new VerificationException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all enrollments associated with the given speaker verification profile permanently from the service
|
||||
*
|
||||
* @param id The speaker ID
|
||||
* @throws ResetEnrollmentsException Thrown in case of invalid ID, failure to reset the profile or an internal server error
|
||||
* @throws IOException Signals a connection abortion, or an invalid response content
|
||||
*/
|
||||
@Override
|
||||
public void resetEnrollments(UUID id) throws ResetEnrollmentsException, IOException {
|
||||
|
||||
String requestUrl = BASE_URI + "/" + id.toString() + "/reset";
|
||||
HttpPost request = (HttpPost) clientHelper.createHttpRequest(requestUrl, RequestType.POST);
|
||||
|
||||
HttpResponse response = defaultHttpClient.execute(request);
|
||||
|
||||
int statusCode = clientHelper.getStatusCode(response);
|
||||
String stringResponse = clientHelper.httpResponseToString(response);
|
||||
|
||||
if (statusCode != HttpStatus.SC_OK) {
|
||||
ErrorResponse errorResponse = gson.fromJson(stringResponse, ErrorResponse.class);
|
||||
if (errorResponse != null) {
|
||||
throw new ResetEnrollmentsException(errorResponse.error.message);
|
||||
} else {
|
||||
throw new ResetEnrollmentsException(String.valueOf(statusCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* An enum encoding the confidence of the identification/verification result
|
||||
*/
|
||||
public enum Confidence {
|
||||
|
||||
/**
|
||||
* The confidence of the identification/verification is low
|
||||
*/
|
||||
@SerializedName("Low")
|
||||
LOW,
|
||||
|
||||
/**
|
||||
* The confidence of the identification/verification is normal
|
||||
*/
|
||||
@SerializedName("Normal")
|
||||
NORMAL,
|
||||
|
||||
/**
|
||||
* The confidence of the identification/verification is high
|
||||
*/
|
||||
@SerializedName("High")
|
||||
HIGH
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract;
|
||||
|
||||
/**
|
||||
* A class encapsulating an exception raised during profile creation
|
||||
*/
|
||||
public class CreateProfileException extends ProfileException {
|
||||
|
||||
/**
|
||||
* A public constructor creating the exception with a specified message
|
||||
*
|
||||
* @param message Exception message
|
||||
*/
|
||||
public CreateProfileException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract;
|
||||
|
||||
/**
|
||||
* A class encapsulating an exception raised during profile deletion
|
||||
*/
|
||||
public class DeleteProfileException extends ProfileException {
|
||||
|
||||
/**
|
||||
* A public constructor creating the exception with a specified message
|
||||
*
|
||||
* @param message Exception message
|
||||
*/
|
||||
public DeleteProfileException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract;
|
||||
|
||||
/**
|
||||
* A class encapsulating a speaker enrollment for verification/identification
|
||||
*/
|
||||
public class EnrollmentBase {
|
||||
/**
|
||||
/* The enrollment status of the profile
|
||||
*/
|
||||
public EnrollmentStatus enrollmentStatus;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract;
|
||||
|
||||
/**
|
||||
* A class encapsulating an exception raised during speaker enrollment
|
||||
*/
|
||||
public class EnrollmentException extends Exception {
|
||||
|
||||
/**
|
||||
* A public constructor creating the exception with a specified message
|
||||
*
|
||||
* @param message Exception message
|
||||
*/
|
||||
public EnrollmentException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* An enum encoding the status of a speaker enrollments for verification/identification
|
||||
*/
|
||||
public enum EnrollmentStatus {
|
||||
|
||||
/**
|
||||
* The profile is currently enrolling and is not ready for verification/identification
|
||||
*/
|
||||
@SerializedName("Enrolling")
|
||||
ENROLLING,
|
||||
|
||||
/**
|
||||
* The profile is currently training and is not ready for verification/identification
|
||||
*/
|
||||
@SerializedName("Training")
|
||||
TRAINING,
|
||||
|
||||
/**
|
||||
* The profile is currently enrolled and is ready for verification/identification
|
||||
*/
|
||||
@SerializedName("Enrolled")
|
||||
ENROLLED
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract;
|
||||
|
||||
/**
|
||||
* A class encapsulating an exception raised during profile(s) retrieval
|
||||
*/
|
||||
public class GetProfileException extends ProfileException {
|
||||
|
||||
/**
|
||||
* A public constructor creating the exception with a specified message
|
||||
*
|
||||
* @param message Exception message
|
||||
*/
|
||||
public GetProfileException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* A class encapsulating the response returned by the service on creating or retrieving a speaker profile
|
||||
*/
|
||||
public class ProfileBase {
|
||||
/**
|
||||
* The speaker profile locale.
|
||||
*/
|
||||
public String locale;
|
||||
|
||||
/**
|
||||
* The timestamp of profile creation
|
||||
*/
|
||||
public Date createdDateTime;
|
||||
|
||||
/**
|
||||
* The timestamp for the last used time for the given profile
|
||||
*/
|
||||
public Date lastActionDateTime;
|
||||
|
||||
/**
|
||||
* The profile enrolling status
|
||||
*/
|
||||
public EnrollmentStatus enrollmentStatus;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract;
|
||||
|
||||
/**
|
||||
* A class encapsulating an exception raised while performing an action on a profile
|
||||
*/
|
||||
public abstract class ProfileException extends Exception {
|
||||
|
||||
/**
|
||||
* A public constructor creating the exception with a specified message
|
||||
*
|
||||
* @param message Exception message
|
||||
*/
|
||||
public ProfileException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract;
|
||||
|
||||
/**
|
||||
* A class encapsulating an exception raised while resetting enrollments for a profile
|
||||
*/
|
||||
public class ResetEnrollmentsException extends ProfileException {
|
||||
|
||||
/**
|
||||
* A public constructor creating the exception with a specified message
|
||||
*
|
||||
* @param message Exception message
|
||||
*/
|
||||
public ResetEnrollmentsException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.identification;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Encapsulates the profile creation response
|
||||
*/
|
||||
public class CreateProfileResponse {
|
||||
|
||||
/**
|
||||
* Speaker profile ID
|
||||
*/
|
||||
public UUID identificationProfileId;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.identification;
|
||||
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.EnrollmentBase;
|
||||
|
||||
/**
|
||||
* This encapsulates the processing result of an enrollment during an identification scenario
|
||||
*/
|
||||
public class Enrollment extends EnrollmentBase {
|
||||
|
||||
/**
|
||||
* Remaining number of speech seconds to complete minimum enrollment.
|
||||
*/
|
||||
public double remainingEnrollmentSpeechTime;
|
||||
|
||||
/**
|
||||
* Seconds of useful speech in enrollment audio.
|
||||
*/
|
||||
public double speechTime;
|
||||
|
||||
/**
|
||||
* Speaker identification profile enrollment length in seconds of speech.
|
||||
*/
|
||||
public double enrollmentSpeechTime;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.identification;
|
||||
|
||||
/**
|
||||
* A class that encapsulates the response from an enrollment operation during an identification scenario
|
||||
*/
|
||||
public class EnrollmentOperation extends Operation {
|
||||
|
||||
/**
|
||||
* The processing result of the enrollment call
|
||||
*/
|
||||
public Enrollment processingResult;
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.identification;
|
||||
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.Confidence;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This encapsulates the processing result of an identification call during an identification scenario
|
||||
*/
|
||||
public class Identification {
|
||||
|
||||
/**
|
||||
* The identified speaker's identification profile ID.
|
||||
* If the speaker is not identified, this value will be "00000000-0000-0000-0000-000000000000".
|
||||
*/
|
||||
public UUID identifiedProfileId;
|
||||
|
||||
/**
|
||||
* The confidence value of the identification.
|
||||
*/
|
||||
public Confidence confidence;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.identification;
|
||||
|
||||
/**
|
||||
* A class encapsulating an exception raised during speaker identification
|
||||
*/
|
||||
public class IdentificationException extends Exception {
|
||||
/**
|
||||
* A public constructor creating the exception with a specified message
|
||||
*
|
||||
* @param message Exception message
|
||||
*/
|
||||
public IdentificationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.identification;
|
||||
|
||||
/**
|
||||
* A class that encapsulates the response from an identification operation during an identification scenario
|
||||
*/
|
||||
public class IdentificationOperation extends Operation {
|
||||
|
||||
/**
|
||||
* The processing result of the identification call
|
||||
*/
|
||||
public Identification processingResult;
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.identification;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* An object encapsulating the state of an identification/enrollment request processed by the service
|
||||
*/
|
||||
public class Operation {
|
||||
|
||||
/**
|
||||
* The operation status
|
||||
*/
|
||||
public Status status;
|
||||
|
||||
/**
|
||||
* The creation date time for the operation request
|
||||
*/
|
||||
public Date createdDateTime;
|
||||
|
||||
/**
|
||||
* The last action date time for the operation
|
||||
*/
|
||||
public Date lastActionDateTime;
|
||||
|
||||
/**
|
||||
* The message in case of failure
|
||||
*/
|
||||
public String message;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.identification;
|
||||
|
||||
/**
|
||||
* An object encapsulating the location of an identification/enrollment request processed by the service
|
||||
*/
|
||||
public class OperationLocation {
|
||||
|
||||
/**
|
||||
* The Url to query enrollment/identification operation status
|
||||
*/
|
||||
public String Url;
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.identification;
|
||||
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.ProfileBase;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A class encapsulating the user profile for an identification tasks
|
||||
*/
|
||||
public class Profile extends ProfileBase {
|
||||
|
||||
/**
|
||||
* Speaker profile ID
|
||||
*/
|
||||
public UUID identificationProfileId;
|
||||
|
||||
/**
|
||||
* The total length of audio - in seconds of speech - submitted for enrollment
|
||||
*/
|
||||
public double enrollmentSpeechTime;
|
||||
|
||||
/**
|
||||
* The remaining audio length -in seconds of speech- for the user to be enrolled
|
||||
*/
|
||||
public double remainingEnrollmentSpeechTime;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.identification;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* An enum to encapsulate the enrollment/identification operation status
|
||||
*/
|
||||
public enum Status {
|
||||
|
||||
/**
|
||||
* The operation has not started yet
|
||||
*/
|
||||
@SerializedName("notstarted")
|
||||
NOTSTARTED,
|
||||
|
||||
/**
|
||||
* The operation is still RUNNING
|
||||
*/
|
||||
@SerializedName("running")
|
||||
RUNNING,
|
||||
|
||||
/**
|
||||
* The operation has finished and FAILED
|
||||
*/
|
||||
@SerializedName("failed")
|
||||
FAILED,
|
||||
|
||||
/**
|
||||
* The operation has finished and SUCCEEDED
|
||||
*/
|
||||
@SerializedName("succeeded")
|
||||
SUCCEEDED
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.verification;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Encapsulates the profile creation response
|
||||
*/
|
||||
public class CreateProfileResponse {
|
||||
/**
|
||||
* Speaker profile ID
|
||||
*/
|
||||
public UUID verificationProfileId;
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.verification;
|
||||
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.EnrollmentBase;
|
||||
|
||||
/**
|
||||
* A class encapsulating a speaker enrollment for a verification task
|
||||
*/
|
||||
public class Enrollment extends EnrollmentBase {
|
||||
/**
|
||||
* The number of remaining enrollments for a profile
|
||||
*/
|
||||
public int remainingEnrollments;
|
||||
|
||||
/**
|
||||
* The current speaker verification profile enrollments count
|
||||
*/
|
||||
public int enrollmentsCount;
|
||||
|
||||
/**
|
||||
* The verification phrase used by the speaker
|
||||
*/
|
||||
public String phrase;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.verification;
|
||||
|
||||
/**
|
||||
* A class encapsulating an exception raised during phrase retrieval
|
||||
*/
|
||||
public class PhrasesException extends Exception {
|
||||
/**
|
||||
* A public constructor creating the exception with a specified message
|
||||
*
|
||||
* @param message Exception message
|
||||
*/
|
||||
public PhrasesException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.verification;
|
||||
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.ProfileBase;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A class encapsulating the response returned by the service on creating or retrieving a speaker profile for a verification service
|
||||
*/
|
||||
public class Profile extends ProfileBase {
|
||||
|
||||
/**
|
||||
* The speaker profile Id
|
||||
*/
|
||||
public UUID verificationProfileId;
|
||||
|
||||
/**
|
||||
* The remaining number of required enrollments if the enrollmentStatus is ENROLLING
|
||||
*/
|
||||
public int remainingEnrollmentsCount;
|
||||
|
||||
/**
|
||||
* The number of existing enrollments
|
||||
*/
|
||||
public int enrollmentsCount;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.verification;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* An enum encoding the verification result
|
||||
*/
|
||||
public enum Result {
|
||||
/**
|
||||
* Result value indicating that the current speaker passed a verification attempt
|
||||
*/
|
||||
@SerializedName("Accept")
|
||||
ACCEPT,
|
||||
|
||||
/**
|
||||
* Result value indicating that the current speaker FAILED a verification attempt
|
||||
*/
|
||||
@SerializedName("Reject")
|
||||
REJECT
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.verification;
|
||||
|
||||
import com.microsoft.cognitive.speakerrecognition.contract.Confidence;
|
||||
|
||||
/**
|
||||
* A class that encapsulates a verification call result
|
||||
*/
|
||||
public class Verification {
|
||||
|
||||
/**
|
||||
* The verification result
|
||||
*/
|
||||
public Result result;
|
||||
|
||||
/**
|
||||
* The verification result confidence
|
||||
*/
|
||||
public Confidence confidence;
|
||||
|
||||
/**
|
||||
* The verification phrase recognized during enrollment
|
||||
*/
|
||||
public String phrase;
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.verification;
|
||||
|
||||
/**
|
||||
* A class encapsulating an exception raised during speaker verification
|
||||
*/
|
||||
public class VerificationException extends Exception {
|
||||
/**
|
||||
* A public constructor creating the exception with a specified message
|
||||
*
|
||||
* @param message Exception message
|
||||
*/
|
||||
public VerificationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/ProjectOxford-ClientSDK
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.cognitive.speakerrecognition.contract.verification;
|
||||
|
||||
/**
|
||||
* A class encapsulating the verification phrase used by the speaker
|
||||
*/
|
||||
public class VerificationPhrase {
|
||||
/**
|
||||
* The verification phrase
|
||||
*/
|
||||
public String phrase;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
include ':lib'
|
Загрузка…
Ссылка в новой задаче