? FMX downgrade with Android TTS

Source: Internet
Author: User

Use of Texttospeech

Official API Address: Texttospeech

FMX downgrade with Android TTS example:

unit main;interfaceuses  system.sysutils, system.types, system.uitypes,  SYSTEM.CLASSES, SYSTEM.VARIANTS,  FMX. TYPES, FMX. CONTROLS, FMX. FORMS, FMX. GRAPHICS, FMX. DIALOGS, FMX. LAYOUTS,  FMX. MEMO, FMX. STDCTRLS, ANDROID.SPEECH.TTS, ANDROIDAPI.JNIBRIDGE,  FMX. SCROLLBOX, FMX. Controls.presentation;type  tformmain = class (tform)     buttonsay:  TButton;    Memo: TMemo;    Switch1: TSwitch;     label1: tlabel;    procedure buttonsayclick (Sender:  TObject);     procedure formcreate (Sender: tobject);  private     type      toninitlistener = class (TJavaLocal,  Jtexttospeech_oninitlistener)       private        [weak] fformmain: tformmain;       Public        constructor create (FormMain: TFormMain);         procedure oninit (Status: integer); cdecl;       end;  private    OnInitListener: TOnInitListener;     TextToSpeech: JTextToSpeech;  public    {  Public declarations }  end;var  formmain: tformmain;implementationuses  ANDROIDAPI.HELPERS, FMX. helpers.android; {$R  *.fmx}constructor tformmain.toninitlistener.create (formmain: tformmain);begin   inherited create;  fformmain := formmain;end;procedure  TFormMain.TOnInitListener.onInit (Status: integer);begin  if status =  Tjtexttospeech_success then    fformmain.buttonsay.enabled := true;end;procedure  Tformmain.buttonsayclick (sender: tobject); begin  if switch1.ischecked  then      texttospeech.setpitch (0.1)  //  set the tone, the greater the value the more The voice (female), the smaller the value becomes male, 1.0 is the general    else     texttospeech.setpitch (1.0); //  set the tone, the greater the value of the voice (female), the smaller the value becomes male, 1.0 is the conventional   texttospeech.speak (Stringtojstring (Memo.text),  tjtexttospeech_queue_add, nil); end; Procedure tformmain.formcreate (Sender: tobject);begin  oninitlistener :=  Toninitlistener.create (self);   texttospeech := tjtexttospeech.javaclass.init ( Sharedactivitycontext, oninitlistener); End;end.




? FMX downgrade with Android TTS

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.