Skip to content

Commit

Permalink
add voice parameter, closes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Shmarkus committed Oct 4, 2018
1 parent 67d2851 commit 7724425
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cordova plugin add cordova-plugin-nuance-speechkit --variable URL=[your URL here
Next, add Ionic native binding
```Bash
npm install --save @ionic-native/speechkit
npm i -s @ionic-native/speechkit
```
Add SpeechKit to your module **providers** section and you are ready

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "cordova-plugin-nuance-speechkit",
"version": "1.0.14",
"version": "2.0.0",
"description": "Cordova Nuance SpeechKit Plugin",
"cordova": {
"id": "cordova-plugin-nuance-speechkit",
"platforms": [
"android"
"android",
"ios"
]
},
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
xmlns:rim="http://www.blackberry.com/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-nuance-speechkit"
version="1.0.13">
version="2.0.0">
<name>Nuance SpeechKit</name>
<description>Cordova Nuance SpeechKit Plugin</description>
<license>Apache 2.0</license>
Expand All @@ -44,7 +44,7 @@

<config-file target="res/xml/config.xml" parent="/*">
<feature name="speechkit" >
<param name="android-package" value="ee.helmes.SpeechKit"/>
<param name="android-package" value="ee.codehouse.SpeechKit"/>
</feature>
</config-file>
<config-file target="res/values/strings.xml" parent="/resources">
Expand All @@ -58,7 +58,7 @@
</config-file>


<source-file src="src/android/SpeechKit.java" target-dir="src/ee/helmes" />
<source-file src="src/android/SpeechKit.java" target-dir="src/ee/codehouse" />
</platform>

<!-- ios -->
Expand Down
6 changes: 4 additions & 2 deletions src/android/SpeechKit.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ee.helmes;
package ee.codehouse;

import android.content.res.Resources;
import android.net.Uri;
Expand All @@ -11,6 +11,7 @@
import com.nuance.speechkit.Session;
import com.nuance.speechkit.Transaction;
import com.nuance.speechkit.TransactionException;
import com.nuance.speechkit.Voice;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
Expand Down Expand Up @@ -56,7 +57,8 @@ private void startTTS(JSONArray args, final CallbackContext callbackContext) {
Transaction.Options options = new Transaction.Options();
final String textToSpeak = args.getString(0);
options.setLanguage(new Language(args.getString(1)));
Log.e(TAG, "Java: will speak: " + textToSpeak);
options.setVoice(new Voice(args.getString(2)));
Log.e(TAG, "Java: will speak: " + textToSpeak + " using voice: " + args.getString(2) + " and language: " + args.getString(1));
Transaction transaction = session.speakString(textToSpeak, options, new Transaction.Listener() {
public void onAudio(Transaction transaction, Audio audio) {
callbackContext.success("Playing audio");
Expand Down
2 changes: 2 additions & 0 deletions src/ios/CDVSpeechKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//
// Created by Adam on 10/3/12.
// Updated by Markus Karileet on 10/7/16
// Updated by Markus Karileet on 17/9/18
//
//

Expand Down Expand Up @@ -30,6 +31,7 @@ - (void) startTTS:(CDVInvokedUrlCommand*)command{
NSLog(@"CDVSpeechKit.startTTS: Entered method.");
SKTransaction* transaction = [session speakString:[command.arguments objectAtIndex:0]
withLanguage:[command.arguments objectAtIndex:1]
withVoice:[command.arguments objectAtIndex:2]
delegate:self];
NSLog(@"CDVSpeechKit.startTTS: Leaving method.");
}
Expand Down
4 changes: 2 additions & 2 deletions www/speechkit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
function SpeechKit() {
}

SpeechKit.prototype.tts = function (text, language, successCallback, failureCallback) {
SpeechKit.prototype.tts = function (text, language, voice, successCallback, failureCallback) {
cordova.exec( successCallback,
failureCallback,
'speechkit',
'startTTS',
[text, language]
[text, language, voice]
);
};

Expand Down

0 comments on commit 7724425

Please sign in to comment.