Does the Watson Text-to-Speech service in Bluemix work for mobile apps? - ibm-cloud

Why doesn't the Watson Text-To-Speech service on Bluemix work for mobile devices? Is this a common issue for outputstream data coming from the server? Thanks!
Edit: Sry, somebody have changed my question totally. I am talking about Text-to-Speech

Text To Speech works in Android, and there is a SDK you can use.
http://watson-developer-cloud.github.io/java-wrapper/
For example, to get all the voices you can do:
import com.ibm.watson.developer_cloud.text_to_speech.v1.TextToSpeech;
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceSet;
TextToSpeech service = new TextToSpeech();
service.setUsernameAndPassword("<username>", "<password>");
VoiceSet voices = service.getVoices();
System.out.println(voices);
where username and password are the credentials you get in Bluemix when you bind the service. You can learn more about the Text to Speech methods by looking at the javadocs here.
It was released today and I made it so let me know if you find any issue.

The Watson Speech-To-Text service is a REST API. You will need to call the REST API from your mobile app. For more info about the REST API check out the API docs.

If you want to use Watson Text-To-Speech for iOS devices it might be handy using Watson-Developer-Cloud SDK for iOS - you might checkout the example on my blumarek.blogspot, just simply build an app in XCode 7.3+:
step 1. use carthage to get all the dependencies:
(create a file cartfile in a project root directory and run the command carthage update --platform iOS)
$ cat > cartfile
# cartfile contents
github "watson-developer-cloud/ios-sdk"
and then you need to add the frameworks to the XCode project - check Step 3: Adding the SDK to the Xcode project on my blumareks.blogpost
step 2. add the code to call the Watson TTS and leverage AVFoundation
(AVFoundation is being deprecated):
- do not forget to add the Watson TTS service in Bluemix.net and get the credentials from it:
{
"credentials": {
"url": "https://stream.watsonplatform.net/text-to-speech/api",
"username": "<service User name>",
"password": "<password>"
}
}
And the code is a plain one:
import UIKit
//adding Watson Text to Speech
import WatsonDeveloperCloud
//adding AVFoundation
import AVFoundation
class ViewController: UIViewController {
#IBOutlet weak var speakText: UITextField!
override func viewDidLoad() {...}
override func didReceiveMemoryWarning() {...}
#IBAction func speakButtonPressed(sender: AnyObject) {
NSLog("speak button pressed, text to say: " + speakText.text!)
//adding Watson service
let service = TextToSpeech(username: "<service User name>", password: "<password>")
service.synthesize(speakText.text!)
{(data, error) in
do {
let audioPlayer = try AVAudioPlayer(data: data!)
audioPlayer.prepareToPlay()
audioPlayer.play()
sleep(10) //the thread needs to live long enough to say your text
} catch {
NSLog("something went terribly wrong")
}
}}}

It is unclear if you are asking about the speech to text or vice versa. The speech to text is covered in most of the questions above and can be referenced on the Watson site -
http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/speech-to-text.html
The Speech to Text service converts the human voice into the written word. This easy-to-use service uses machine intelligence to combine information about grammar and language structure with knowledge of the composition of the audio signal to generate a more accurate transcription. The transcription is continuously sent back to the client and retroactively updated as more speech is heard. Recognition models can be trained for different languages, as well as for specific domains.

If you look at this github project https://github.com/FarooqMulla/BluemixExample/tree/master which uses the Old SDK
There is an example that uses the real time speech to text api which sends audio packets to bluemix and receives back the transcribed string in real time.
Beware as of 1/22/16 the new Swift based SDK is broken for this particular functionality.

Related

How to fix AppStore rejection "Your app requests admin access in order to function" for macOS

I'm currently developing an App that contains a XPC Service embedded.
The App starts in background and communicates with the XPC Service in order to make the service move the mouse from time to time.
My app review by Apple returned this:
Guideline 2.4.5(v) - Performance
Your app requests admin access in order to function.
- App requires Accessibility in order to function.
Resources
An informational video concerning requesting access from users is available from our WWDC 2019 conference. See the Advances in macOS Security video.
AppDelegate.swift
func applicationDidFinishLaunching(_ aNotification: Notification) {
connection = NSXPCConnection(serviceName: "com.some.ServiceName")
connection?.remoteObjectInterface = NSXPCInterface(with: MyHelperXPCProtocol.self)
connection?.resume()
}
MyHelperXPC.swift (XPC Service Target)
import Foundation
import Cocoa
#objc class MyHelperXPC: NSObject, MyHelperXPCProtocol {
func terminateHelper() {
}
/* This function triggers the dialog informing that the app would like
to control this computer using accessibility features. */
func activate(duration: TimeInterval) {
CGEvent(mouseEventSource: nil, mouseType: CGEventType.mouseMoved, mouseCursorPosition: point, mouseButton: CGMouseButton.left)?.post(tap: CGEventTapLocation.cghidEventTap)
}
}
When the function 'activate' is called this dialog is shown:
The user now have to unlock Security & Privacy preferences and check my App.
After this, my application can now move the mouse without a problem.
XPC Service Info.plist contains:
com.apple.security.app-sandbox = 1
App Info.plist contains:
Application is background only = YES
The question is, how can I understand better this App Store rejection and fix it?
My App and XPC Service are signed with a Developer ID Application.
I'm using Xcode 12.4, macOS Big Sur and swift 5, not using frameworks.
After appealing to the Apple Review Board, turned out that moving the mouse using the Accessibility is considered inappropriate.
I understand that using the Accessibility this way exploits the feature originally designed to make your app more accessible for people.
They also wrote that will look into other apps that have the same functionality because they may be considered inappropriate as well.

Swift Cocoa: WKWebView Twilio Error: Client is unable to create apply a local media description. Error Code: 53400

I am developing a Cocoa app that using TwilioVideo. Since TwilioVideo SDK is only built for iOS and not worked for macOS so I wanted to create an approach using Twilio with the shared weblink and work it with WKWebView in Cocoa. I start with
let pRoom = URL(string: "https://meetingroomfortwilio.com/room/roomid")!
let request = URLRequest(url: pRoom)
videoWebView.load(request)
in viewDidLoad method.
It opened the communication web page but with error like below.
I searched for error and learned that these problems via Twilio official API errors page.
The Client may not be using a supported WebRTC implementation.
The Client may not have the necessary resources to create or apply a new media description.
So, good or bad, I have to implement a video call system in Cocoa for the app.
How can I implement supported WebRTC implementation for my app in Cocoa?
What would you do for a building an app with WebRTC (video & voice call)?
Is opened a Safari browser from the app good approach for building this and can I track the browser which I opened for the video-voice call, situations like success, error?
I would like to learn how to achieve the problem, maybe in different ways?
Thanks in advance!

Back4app with Stripe using swift iOS

I'm trying to build an iOS app with back4app acting as the db. I've added Stripe to the cloud code and I've added all the relevant API keys to it.
I've been following https://www.back4app.com/docs/cloud-code-functions/stripe-android-app as documentation.
Being an Android app, I'm not sure which cloud code functions I should use when trying to test a payment using Swift.
Hope someone can help. Thanks.
Back4App utilises the open source Parse Server and the wider Parse Platform including our open source client SDKs for iOS, Android, JavaScript, Flutter, PHP and more.
With this in mind much of our open source documentation is relevant to using Back4App. The extensive guides should help get you up to speed and answer most simple questions.
Following on from #Paul's suggestion, to call a cloud function using the iOS SDK you can do something like this...
PFCloud.callFunction(inBackground: "purchaseItem", withParameters: nil) { (result, error) in
guard error == nil else {
return
}
guard let result = result as? String else {
return
}
print("Wow \(result).")
}

How can I play a sound in Twilio's Autopilot?

I would like to see if I can play a voice recording to remove twilio's Autopilot robot voice, any idea on how to do this? Or if it's even possible?
Twilio developer evangelist here.
You can specify a voice with Amazon Polly using StyleSheets, a declarative API responsible for dialogue, state management, and error handling that can be used to control an Assistant's tone, language, and more.
In Node.js, you could update a StyleSheet to use a different voice like this (make sure your Twilio helper library is updated to a more recent version as this is a new functionality!). Here, your Autopilot Assistant's voice would be Joanna.
client.autopilot.assistants('REPLACE-WITH-YOUR-AUTOPILOT-ASSISTANT-SID')
.styleSheet()
.update({
styleSheet: {
style_sheet: {
voice: {
say_voice: 'Polly.Joanna'
}
}
}
})
.then(style_sheet => console.log(style_sheet.assistantSid));

I have an Alexa skill. How do I make it work with Google Home?

I’ve already built an Alexa skill, and now I want to make that available on Google Home. Do I have to start from scratch or can I reuse its code for Actions on Google?
Google Assistant works similar to Amazon Alexa, although there are a few differences.
For example, you don't create your language model inside the "Actions on Google" console. Most Google Action developers use DialogFlow (formerly API.AI), which is owned by Google and offers a deep integration. DialogFlow offered an import feature for Alexa Interaction models, which doesn't work anymore. Instead, you can take a look at this tutorial: Turn an Alexa Interaction Model into a Dialogflow Agent.
Although most of the work for developing voice apps is parsing JSON requests and returning JSON responses, the Actions on Google SDK works different compared to the Alexa SDK for Node.js.
To help people build cross-platform voice apps with only one code base, we developed Jovo, an open-source framework that is a little close to the Alexa SDK compare to Google Assistant. So if you consider porting your code over, take a look, I'm happy to help! You can find the repository here: https://github.com/jovotech/jovo-framework-nodejs
It is possible to manually convert your Alexa skill to work as an Assistant Action. Both a skill and an action have similar life cycles that involve accepting incoming HTTP requests and then responding with JSON payloads. The skill’s utterances and intents can be converted to an Action Package if you use the Actions SDK or can be configured in the API.ai web GUI. The skill’s handler function can be modified to use the Actions incoming JSON request format and create the expected Actions JSON response format. You should be able to reuse most of your skill’s logic.
This can be done but it will require some work and you will not have to rewrite all of your code.
Check out this video on developing a Google Home Action using API.AI (that is recommended).
Once you have done the basics and started understanding how Google Home Actions differ from Amazon Alexa Skills, you can simply transfer your logic over to be similar. The idea of intents are very similar but they have different intricacies that you must learn.
When you execute an intent it seems as if your app logic will be similar in most cases. It is just the setup, deploying and running that are different.