SpiderBasic Voice! (Speech API - Chrome)

Created a nice software using SpiderBasic ? Post you link here !
User avatar
eddy
Posts: 124
Joined: Thu Mar 27, 2014 8:34 am

SpiderBasic Voice! (Speech API - Chrome)

Post by eddy »

Sorry, I don't how to run this code on FireFox :?

updated: lang option from falsam

Code: Select all

Enumeration
  #WIN=100
  #BUTTON
  #BUTTON_FR
  #BUTTON_DE
  #STRING_GADGET
EndEnumeration

Procedure ReadText()
  txt.s=GetGadgetText(#STRING_GADGET)
  !var msg = new SpeechSynthesisUtterance(v_txt);
  !msg.voice = speechSynthesis.getVoices().filter(function(voice) { return voice.name == 'Whisper'; })[0];
  Select EventGadget()
    Case #BUTTON_FR
      !msg.lang = 'fr-FR';
    Case #BUTTON_DE   
      !msg.lang = 'de-DE';
  EndSelect   
  !speechSynthesis.speak(msg);
EndProcedure


If OpenWindow(#WIN, 0, 0, 640, 480, "Speech API - HTML5", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)  
  StringGadget(#STRING_GADGET,5,5,500,20,"SpiderBasic rox du poney!")
  ButtonGadget(#BUTTON,5,40,200,20,"Talk!")
  ButtonGadget(#BUTTON_FR,5,70,200,20,"Parle!")
  ButtonGadget(#BUTTON_DE,5,100,200,20,"Sprechen!")
  BindGadgetEvent(#BUTTON, @ReadText())
  BindGadgetEvent(#BUTTON_FR, @ReadText())
  BindGadgetEvent(#BUTTON_DE, @ReadText())
EndIf
Last edited by eddy on Mon May 05, 2014 10:50 pm, edited 3 times in total.
falsam
Posts: 280
Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:

Re: SpiderBasic Voice! (Speech API - Chrome)

Post by falsam »

Thanks Eddy. :)

For voice in French , pour avoir la voix en français.

Code: Select all

Procedure ReadText()
  txt.s=GetGadgetText(#STRING_GADGET)
  !var msg = new SpeechSynthesisUtterance(v_txt);
  !msg.voice = speechSynthesis.getVoices().filter(function(voice) { return voice.name == 'Whisper'; })[0];
  !msg.lang = 'fr-FR';
  !speechSynthesis.speak(msg);
EndProcedure
German

Code: Select all

!msg.lang = 'de-DE';
etc ...

:idea: Introduction to the Speech Synthesis API

➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
http://falsam.com

Sorry for my poor english
Post Reply