は、私はここにあなたが2で行くことができるHTMLの解析とtext2speechで働いていた下記のコードでHTMLファイルから し1.Get属性文字列ステップたようiOS7+
あなたのクライアントの観点 1として
で動作します。if HTML2Speechが有料であるか、 であれば、そのAPIに依存しているAPIがあります。ネイティブフレームワーク は、you/clientが望むものと同じものに役立ちます。
ステップ1:HTML2Stringを取得するための方法を以下 使用:
/**
* "ConvertHTMLtoStrAndPlay" : This method will convert the HTML to String
synthesizer.
*
* @param aURLHtmlFilePath : "object of html file path"
*/
-(void)ConvertHTMLtoStrAndPlay:(UIButton*)aBtnPlayPause
isSpeechPaused:(BOOL)speechPaused
stringWithHTMLAttributes:(NSAttributedString*)aStrWithHTMLAttributes
{
if (synthesizer.speaking == NO && speechPaused == NO) {
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:aStrWithHTMLAttributes.string];
//utterance.rate = AVSpeechUtteranceMinimumSpeechRate;
if (IS_ARABIC) {
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"ar-au"];
}else{
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-au"];
}
[synthesizer speakUtterance:utterance];
}
else{
[synthesizer pauseSpeakingAtBoundary:AVSpeechBoundaryImmediate];
}
if (speechPaused == NO) {
[synthesizer continueSpeaking];
} else {
[synthesizer pauseSpeakingAtBoundary:AVSpeechBoundaryImmediate];
}
}
[[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUTF8StringEncoding]
options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)}
documentAttributes:nil error:nil];
次に、あなたはAVSpeechUtterance
ステップ2でこの属性付き文字列を渡すことができます
いつものように、音声を止めるにはコードの下での使用を止める必要があります。
/**
* "StopPlayWithAVSpeechSynthesizer" : this method will stop the playing of audio on the application.
*/
-(void)StopPlayWithAVSpeechSynthesizer{
// Do any additional setup after loading the view, typically from a nib.
[synthesizer stopSpeakingAtBoundary:AVSpeechBoundaryImmediate];
}
希望これは、HTML2Speech機能を取得するのに役立ちます。
はい!あなたは修正形式のHTMLを持っていますか? – amorbytes
いいえHTMLファイルの定型書式はありません。 – CodeChanger
「彼はHTML2Speech機能を直接提供しているAPIまたはフレームワークを望んでいます」、これを行うAPIはすべて、基になるHTMLを解析してText2Speechに送ります。他の方法はありません。 – Kevin