Closed shikida closed 8 years ago
In Eclipse, you can have:
A Maven/Gradle project where you specify the dependency:
Maven
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>java-sdk</artifactId>
<version>3.5.0</version>
</dependency>
Gradle
'com.ibm.watson.developer_cloud:java-sdk:3.5.0'
Create a Java class with a main
static method like the following:
/**
* Recognize a sample wav file and print the transcript into the console output. Make sure you are using UTF-8 to print
* messages; otherwise, you will see question marks.
*/
public class SpeechToTextExample {
public static void main(String[] args) {
SpeechToText service = new SpeechToText();
service.setUsernameAndPassword("<username>", "<password>");
File audio = new File("sample1.wav");
SpeechResults transcript = service.recognize(audio).execute();
System.out.println(transcript);
}
}
Replace the sample1.wav
, <username>
, and <password>
with valid values and you will get a working sample.
sorry, I just had to right click on the maven project Maven->Update Maven Project->Force Update of Snapshots/Releases
I've created a brand maven project in eclipse using this pom
I'm getting the "missing artifact" error
In fact, if I go to
https://mvnrepository.com/artifact/com.ibm.watson.developer_cloud/java-wrapper
last version is 1.1.1
however, the same site says these are valid
(not 3.5.0 as the main github page says)
So I am using the following POM
and then I try to run
notice that this is the same example code from the main github page, however, using a notation that is supposed to run and to compile, because the examples in the main page are outdated.
also, I am using the wave file from
https://github.com/watson-developer-cloud/java-sdk/blob/master/tests/src/test/resources/speech_to_text/sample1.wav
then I get the following error message
so OK, it seems I am missing some library, let's try another POM
(because 3.4.0 and 3.5.0 don't work in eclipse)
Now the code compiles, but the request returns
So I think I am out of tricks.
Any help is welcome.