Speech recognition Complete verse query function, IOS avspeechsynthesis Voice output result of the poetry app

Source: Internet
Author: User

Objective

The current application of the query is to use manual input, not only inefficient, and query the limit of the statement is relatively large, can not be easily extended. If you can easily expand the query statement, then the use of the app will have a lot of flexibility. can design a variety of questions and statements, you can easily interact with the user. The speech platform interface provided by the Olami platform is used here, which makes it easy to extend the query statement and return the desired result. At the same time, the Olami platform also provides a complete speech recognition function, combined with the Avspeechsynthesis interface provided by iOS, you can implement an app like Siri's smart voice query verse.

App Feature Introduction

This is a query "300 Tang Poems", "Song CI 300", "Yuanqu 300" Poetry learning app, you can query the name query poetry, can be queried by the poet poetry, can be queried through the poem is which, you can query the Tang Dynasty, which poets, what is the masterpiece of these poets. and read it through the voice.
Through the poet search masterpiece, click can display poetry

Search by poem Name

Querying poetry through verses

Querying Poets by verse

Implementation of the function

Both speech recognition and semantic understanding are realized through the Olami platform. This need to go to the Olami platform to register, and then you can try it for free. Website address Https://olami.ai, the site has a wealth of teaching resources specific use can view the relevant documents, you can also query my previous blog
The statements that are defined are mostly queries: for example,
The flower season again every June from which poem
Will you recite Li Bai's poems?
What are the poets of the Yuan Dynasty?
What poets are there in the Tang Dynasty
What are the main works of Tang Dynasty poet Li Bai

The poems of Li Shangyin

The reading of the voice is done using Apple's avspeechsynthesis library. This library is also very easy to use. This library is in the avfoundation.

#import<AVFoundation/AVFoundation.h>

Two classes are used

AVSpeechSynthesizerAVSpeechUtterance
AVSpeechSynthesizer *av= [[AVSpeechSynthesizer alloc]init];av.delegate=self;//挂上代理AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc]initWithString:@"你好!"];//需要转换的文字 utterance.rate=0.5;// 设置语速,范围0-1,注意0最慢,1最快;AVSpeechUtteranceMinimumSpeechRate最慢,AVSpeechUtteranceMaximumSpeechRate最快 AVSpeechSynthesisVoice*voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-TW"];//设置发音,这是中文普通话 utterance.voice= voice;[av speakUtterance:utterance];//开始

Avspeechsynthesizer defines a number of callback proxies that can detect some states

-(void) SpeechSynthesizer:(avspeechsynthesizer*) Synthesizer didstartspeechutterance:(avspeechutterance*) utterance{NSLog(@"---start playing");} -(void) SpeechSynthesizer:(avspeechsynthesizer*) Synthesizer didfinishspeechutterance:(avspeechutterance*) utterance{NSLog(@"---complete playback");} -(void) SpeechSynthesizer:(avspeechsynthesizer*) Synthesizer didpausespeechutterance:(avspeechutterance*) utterance{NSLog(@"---play Abort");} - (void) SpeechSynthesizer:(avspeechsynthesizer*) synthesizer didcontinuespeechutterance:(  avspeechutterance*) utterance{NSLog(@"---resume Playback");} - (void) SpeechSynthesizer:(avspeechsynthesizer*) synthesizer didcancelspeechutterance:(  avspeechutterance*) utterance{NSLog(@"---play Cancel");}          

Speech recognition Complete verse query function, IOS avspeechsynthesis Voice output result of the poetry app

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.