I retried the following
The error related to the subscription key is gone, but now I am getting a link error. Can you please help me figure this one out?
Preparation
Install Azul Zulu OpenJDK
Install Microsoft Build of OpenJDK
Install Apache Maven
Installed Speech SDK Maven
Install Android Studio Chipmunk 2021.2.1
Create a Cognitive services multi-service account
Set the system environment variable SPEECH_KEY to key 1 of the Cognitive services multiservice account.
Set the system environment variable SPEECH_REGION to japaneast of the Cognitive services multiservice account.
Create a voice service account.
Install Cygwin.
- Launch AndroidStudio.
- Select File->New Project->Phone and Tablet->Empty Activity and press Next
- Enter "SpeechQuickstart" in the Name field.
- In PackageName, enter samples.speech.cognitiveservices.microsoft.com
- Select any directory in Save location.
- Select java in Language.
- Under Minimum API lvel, select API 23.
- Press "Finish
9.Select File->Project Structure->Dependncies->app
10.Select +->Library dependency
11.Enter com.microsoft.cognitiveservices.speech:client-sdk in step1 and press Search - com.microsoft.cognitiveservices.speech will appear and press OK.
13.Press OK to close Project Structure. - Press File->Sync Project With Gradle Files
- Right click on SpeechQuickStart in the Project window of AndroidStudio
16.New->File to generate pom.xml - Write the following contents in pom.xml <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 ">
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.cognitiveservices.speech.samples</groupId>
<artifactId>quickstart-eclipse</artifactId>
<version>1.0.0-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>maven-cognitiveservices-speech</id>
<name>Microsoft Cognitive Services Speech Maven Repository</name>
<url>https://azureai.azureedge.net/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.microsoft.cognitiveservices.speech</groupId>
<artifactId>client-sdk</artifactId>
<version>1.24.1</version>
</dependency>
</dependencies>
</project> - Start Cygwin and navigate to the location where pom.xml is located.
- Run mvn clean dependency:copy-dependencies
- Add the following to MainActivity.java import com.microsoft.cognitiveservices.speech.*;
import com.microsoft.cognitiveservices.speech.audio.AudioConfig; public class MainActivity extends AppCompatActivity {
}private static String speechKey = System.getenv("SPEECH_KEY"); private static String speechRegion = System.getenv("SPEECH_REGION"); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SpeechConfig speechConfig = SpeechConfig.fromSubscription(speechKey, speechRegion); }
error message
FATAL EXCEPTION: main
Process: samples.speech.cognitiveservices.microsoft.com, PID: 4132
java.lang.UnsatisfiedLinkError: No implementation found for void com.microsoft.cognitiveservices.speech.SpeechConfig.setTempDirectory(java.lang.String) (tried Java_com_microsoft_cognitiveservices_speech_SpeechConfig_setTempDirectory and Java_com_microsoft_cognitiveservices_speech_SpeechConfig_setTempDirectory__Ljava_lang_String_2)
at com.microsoft.cognitiveservices.speech.SpeechConfig.setTempDirectory(Native Method)
at com.microsoft.cognitiveservices.speech.SpeechConfig.<clinit>(Unknown Source:55)
at com.microsoft.cognitiveservices.speech.SpeechConfig.fromSubscription(Unknown Source:0)
at samples.speech.cognitiveservices.microsoft.com.MainActivity.onCreate(MainActivity.java:18)
at android.app.Activity.performCreate(Activity.java:8051)
at android.app.Activity.performCreate(Activity.java:8031)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3608)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3792)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)