I want to save audio file generated by TTS SDK.
I am not sure what is correct way to do it with NSURL path.
This is the code, but result says NO.
If I don’t try saving audio file, MyAcaTTS works fine.
NSString *FileNamePath = [[NSBundle mainBundle] pathForResource:@"testAudio" ofType:@"aiff"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appSettingsPath = [documentsDirectory stringByAppendingPathComponent:FileNamePath];
NSURL *url=[[NSURL alloc]initWithString:appSettingsPath];
BOOL result = [MyAcaTTS_ startSpeakingString:@"testing" toURL:url];
Document of Acapela iPhone SDK.
6.2.3.startSpeakingString:toURL:
Synopsis
- (BOOL)startSpeakingString:(NSString *)string toURL:url;
Description
Begins synthesizing string into a sound (AIFF) file.
When synthesis of string finishes normally or is stopped, the message
speechSynthesizer:didFinishSpeaking: is sent to the delegate. Parameters
string
Text to synthesize. When nil or empty, no synthesis occurs.
url
Filesystem location of the output sound file. Return value
YES when synthesis starts successfully, NO otherwise.
http://www.ecometrixem.com/cms-assets/documents/44729-919017.acapela-for-iphone.pdf
There are two things for you to consider in your code:
The line
NSString *FileNamePath = [[NSBundle mainBundle] pathForResource:@"testAudio" ofType:@"aiff"];is not required since it returns full path of the file while you need only the last part of it: “testAudio.aiff”
You construct URL object with constructor accepting strings with valid protocol prefix, like “http://” or “ftp://” while your need another constructor named
initFileURLWithPath:instead.So with all the above your code may look like this: