In the IOS app, the video SDK features detailed

Source: Internet
Author: User

Go to: http://www.sufeinet.com/thread-2488-1-1.html

How to use the CyberLink Voice SDK to add to your iphone app!

1. First, please go to the developer Zone (http://open.voicecloud.cn/developer.php) of the official website of the Flying News. If you haven't registered yet, you'll need to register a developer account first. Click "Free Registration" at the top of the website to register an account with your own mobile phone number.

2. You can also use the SDK only if you have registered a developer account, as you will also need to apply for AppID. After landing to your own personal center to create an application fill in the relevant information, and then wait for approval, because only after the approval, you can download the voice of the audio SDK. As follows:
<ignore_js_op>




3. If your app has been approved, click the SDK download and select the SDK for the platform, such as now select iphone Platform SDK download.

4. Once downloaded, you will see a compressed package, extracted with four files,
<ignore_js_op>



Where sample is the demo of the flight provided, open the project, you will see such a directory structure:
<ignore_js_op>



Run directly, and no errors, only a few warnings, run the interface as follows:
<ignore_js_op>

< ignore_js_op>



5. How do you use it in your own projects? In fact, it's very simple. We also provide relevant development documentation, or more detailed. There are documents available for download in the developer zone and in the download area.

6. Create an iphone project. Once you are done, you need to import the required lib, as follows:
<ignore_js_op>


It should be explained that Iflymsc.framework this lib is in the download of the SDK extracted files under the Lib folder. In the Add Lib interface choose Add Others ..., and select the Lib you downloaded. Click Open to add it correctly.
<ignore_js_op>



7. Description of some functions and configurations:

Import the file in the header file that you need to use the SDK:

    1. #import "Iflymsc/iflyrecognizecontrol.h"
    2. #import "Iflymsc/iflysynthesizercontrol.h"
Copy Code

Create a recognition control or composition control:

    1. Iflyrecognizecontrol *_iflyrecognizecontroller; Knowledge control
    2. Iflysynthesizercontrol *_iflysynthesizercontrol; Compositing controls
Copy Code

In the implementation of the file initialization control:

  1. Initializing the language knowledge control
  2. _iflyrecognizecontroller = [[Iflyrecognizecontrol alloc] Initwithorigin:cgpointmake (+) Initparam:initpara];
  3. [Self.view Addsubview:_iflyrecognizecontroller];
  4. Configure
  5. [_iflyrecognizecontroller setengine:@ "SMS" Engineparam:nil Grammarid:nil];
  6. [_iflyrecognizecontroller setsamplerate:16000];
  7. [_iflyrecognizecontroller setdelegate:self];
  8. [_iflyrecognizecontroller Setshowlog:no];
  9. Register Unactive Event
  10. [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (resignactive) Name: Uiapplicationwillresignactivenotification Object:nil];
  11. Initialize the language composition control
  12. _iflysynthesizercontrol = [[Iflysynthesizercontrol alloc] Initwithorigin:cgpointmake (+) Initparam:initpara];
  13. Configure
  14. [_iflysynthesizercontrol setdelegate:self];
  15. [_iflysynthesizercontrol setvoicename:@ "VIXM"]; Pronunciation Person (Chinese and English Cantonese language)
  16. [Self.view Addsubview:_iflysynthesizercontrol];
  17. Show UI
  18. [_iflysynthesizercontrol Setshowui:yes];
  19. Show log
  20. [_iflysynthesizercontrol Setshowlog:no];
  21. Register Unactive Event
  22. [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (resignactiveofsynthesizer) Name: Uiapplicationwillresignactivenotification Object:nil];
Copy Code

Some callback functions and methods:

  1. Knowledge of the end of the function-the number of thread to adjust this function
  2. -(void) Onrecognizeend: (Iflyrecognizecontrol *) Iflyrecognizecontrol theerror: (int) error
  3. {
  4. [_recognizebutton Setenabled:yes];
  5. [_synthesizerbutton Setenabled:yes];
  6. NSLog (@ "knowledge ends");
  7. NSLog (@ "Traffic:%d, download traffic:%d", [Iflyrecognizecontrol Getupflow:false],[iflyrecognizecontrol getdownflow:false]);
  8. }
  9. Knowledge return function
  10. -(void) Onresult: (Iflyrecognizecontrol *) Iflyrecognizecontrol Theresult: (Nsarray *) resultarray
  11. {
  12. NSString *strresult = [[Resultarray objectatindex:0] objectforkey:@ "NAME"];
  13. NSLog (@ "Knowledge of the results are:%@", strresult);
  14. }
  15. Start language knowledge
  16. -(void) onbuttonrecognize
  17. {
  18. if ([_iflyrecognizecontroller start]) {
  19. [_recognizebutton Setenabled:no];
  20. [_synthesizerbutton Setenabled:no];
  21. }
  22. }
  23. The back mode is not supported in the Unactive event.
  24. -(void) resignactive
  25. {
  26. [_iflyrecognizecontroller Cancel];
  27. }
  28. Synthetic back function, execute cancel function The whole conversation ends with this function.
  29. -(void) Onsynthesizerend: (Iflysynthesizercontrol *) Iflysynthesizercontrol theerror: (int) error
  30. {
  31. [_synthesizerbutton Setenabled:yes];
  32. [_recognizebutton Setenabled:yes];
  33. NSLog (@ "End of the bundle");
  34. NSLog (@ "Traffic:%d, download traffic:%d", [Iflysynthesizercontrol Getupflow:false],[iflysynthesizercontrol getdownflow:false]);
  35. }
  36. Gain player Cache level
  37. -(void) onsynthesizerbufferprogress: (float) bufferprogress
  38. {
  39. NSLog (@ "pre-buffer:%f", bufferprogress);
  40. }
  41. Access to player playback
  42. -(void) onsynthesizerplayprogress: (float) playprogress
  43. {
  44. NSLog (@ "pre-play:%f", playprogress);
  45. }
  46. Start tone synthesis
  47. -(void) Onbuttonsynthesizer
  48. {
  49. [_iflysynthesizercontrol settext:@ "Haha, this is just an example of a test synthesis function, you don't have to be too nervous about what happens in particular." Thank you "Params:nil";
  50. if ([_iflysynthesizercontrol start]) {
  51. [_recognizebutton Setenabled:no];
  52. [_synthesizerbutton Setenabled:no];
  53. } else {
  54. NSLog (@ "I ' m sorry,start error. ");
  55. }
  56. }
  57. Do not support the back-mode unactive event.
  58. -(void) Resignactiveofsynthesizer
  59. {
  60. NSLog (@ "resignactive");
  61. [_iflysynthesizercontrol Cancel];
  62. }
Copy Code

The following methods can be called where you need to start using speech functions, such as:

  1. _recognizebutton = [UIButton buttonwithtype:uibuttontyperoundedrect];
  2. _synthesizerbutton = [UIButton buttonwithtype:uibuttontyperoundedrect];
  3. [_recognizebutton Setframe:cgrectmake (70, 100, 180, 60)];
  4. [_synthesizerbutton Setframe:cgrectmake (70, 200, 180, 60)];
  5. [_recognizebutton settitle:@ "Start language knowledge" forstate:uicontrolstatenormal];
  6. [_synthesizerbutton settitle:@ "Start the synthesis of the language forstate:uicontrolstatenormal];
  7. [_recognizebutton addtarget:self Action: @selector (Onbuttonrecognize) Forcontrolevents:uicontroleventtouchdown];
  8. [_synthesizerbutton addtarget:self Action: @selector (Onbuttonsynthesizer) Forcontrolevents:uicontroleventtouchdown ];
  9. [Self.view Addsubview:_recognizebutton];
  10. [Self.view Addsubview:_synthesizerbutton];
  11. Start language knowledge
  12. -(void) onbuttonrecognize
  13. {
  14. if ([_iflyrecognizecontroller start]) {
  15. [_recognizebutton Setenabled:no];
  16. [_synthesizerbutton Setenabled:no];
  17. }
  18. }
  19. Start tone synthesis
  20. -(void) Onbuttonsynthesizer
  21. {
  22. [_iflysynthesizercontrol settext:@] This is just an example of a test synthesis function, you don't have to be too nervous about what happens "Params:nil";
  23. if ([_iflysynthesizercontrol start]) {
  24. [_recognizebutton Setenabled:no];
  25. [_synthesizerbutton Setenabled:no];
  26. } else {
  27. NSLog (@ "I ' m sorry,start error. ");
  28. }
  29. }
Copy Code

8. It is now possible to use speech recognition and compositing functions. As follows:
<ignore_js_op>

< ignore_js_op>

< ignore_js_op>

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.