p5.speech library

255 views
Skip to first unread message

roberto...@gmail.com

unread,
Dec 3, 2020, 9:06:08 PM12/3/20
to Glowscript Users
Inspired by the math and numjs libraries conversation,
I got p5.speech to work somewhat.

I use Windows10.
The selection of voices is a little different when running in Chrome.

(I couldn't get speechRec to work yet.)

(An error occurs if the print statement is uncommented.
It seems the error is associated with the get_library command for p5.min.js .
[Comment out all of the voice statements except for this get_library statement.]
)

Rob S.



GlowScript 3.0 VPython

#
# robphy (12/03/2020)
# using p5.speech
#

R=5

S0=sphere()
S=sphere(pos=R*vector(1,0,0),color=color.red)

voc = new p5.Speech()
voc.interrupt=False
voc.speak('glowscript is')
voc.setPitch(1.9)
voc.speak('way cool')
voc.interrupt=True # voc.cancel()
sleep(1)

t=0
dt=0.02
twopi=2*pi
while(True):
  
  rate(30) #not too fast!
  t +=dt

  S.pos=R*vector(cos(t*twopi),sin(t*twopi),0)
  if floor(t+dt)>floor(t):
    
    voc.setVoice(floor(29*random()+0.5))
    voc.setPitch(0.01+random()*1.99)
    voc.setRate(0.5+random()*1.5)
    voc.speak(floor(t+dt))
  #print(S.pos)   # uncommenting will cause an error (due to p5.min.js?? )
 

Bruce Sherwood

unread,
Dec 4, 2020, 12:06:23 PM12/4/20
to Glowscript Users
I tried this in Chrome on Windows 10 and got lots of errors, as seen when I ran the following with the console enabled (Ctrl-Shift-j):

console.log('====================================')
console.log('====================================')
console.log('====================================')
console.log('====================================')
voc = new p5.Speech()

This included a warning which I don't understand: The deviceorientation events are blocked by feature policy. See https://github.com/WICG/feature-policy/blob/master/features.md#sensor-features

Bruce

roberto...@gmail.com

unread,
Dec 26, 2020, 2:09:38 PM12/26/20
to Glowscript Users
My p5.speech attempt on Glowscript on trinket.io has been updated 
to use newer libraries (1.2.0 vs 0.4.5) ... apparently p5.dom.js isn't needed for the code to run.
Various errors are still triggered in the console (Ctrl-Shift-j).

Rob S.


Bruce Sherwood

unread,
Dec 26, 2020, 2:29:29 PM12/26/20
to Glowscript Users
That's good news. There remain some problems with the speech library, because even my stripped-down html file fails on Chrome (but works in Edge and Firefox).

Bruce

pri...@gmail.com

unread,
Dec 26, 2020, 5:06:41 PM12/26/20
to Glowscript Users
Great improvements!
But now I get a different error:
TypeError: color.to_html_rgba is not a function
when I run my (somewhat crazy, unfinished) project:


Poul Riis

pri...@gmail.com

unread,
Dec 26, 2020, 5:14:28 PM12/26/20
to Glowscript Users
... and the following error:
Error: sphere() is only supported in WEBGL mode. If you'd like to use 3D graphics and WebGL, see https://p5js.org/examples/form-3d-primitives.html for more information.
from

Poul Riis

lørdag den 26. december 2020 kl. 20.29.29 UTC+1 skrev Bruce Sherwood:
Reply all
Reply to author
Forward
0 new messages