vrSpeech demo

speech.py
 1# © 2024 Autodesk, Inc. All rights reserved.
 2
 3newScene()
 4
 5scene = loadGeometry("$VRED_EXAMPLES/geo/teddy.osb")
 6updateScene()
 7
 8# define speech input command show
 9speechShow = vrSpeech("show")
10speechShow.connect(updateScene)
11vrLogWarning("Say show to update the scene")
12
13# define speech input command left
14speechLeft = vrSpeech("left")
15speechLeft.connect("setFrom(-1, -110.770012, 4.201654, 0.591690);setUp(-1, 0,1,0)")
16vrLogWarning("Say left to look from the left")
17
18# define speech input command right
19speechRight = vrSpeech("right")
20speechRight.connect("setFrom(-1, 110.256012, 11.424259, 1.052248);setUp(-1, 0,1,0)")
21vrLogWarning("Say right to look from the right")
22
23# define speech input command top
24speechTop = vrSpeech("top")
25speechTop.connect("setFrom(-1, 0.797391, 110.598511, 7.438207);setUp(-1, 0,0,-1)")
26vrLogWarning("Say top to look from the top")
27
28# define speech input command bottom
29speechBottom = vrSpeech("bottom")
30speechBottom.connect("setFrom(-1, 1.820974, -110.831238, 1.058094);setUp(-1, 0,0,1)")
31vrLogWarning("Say bottom to look from the top")
32
33# define speech input command name
34speechName = vrSpeech("name")
35speechName.connect("speak('My name is vreeed')")
36vrLogWarning("Say name to hear the name of the application")
37
38# rotation
39scene.makeTransform()
40
41sceneRotate = vrInterpolator()
42
43# Das dreht einfach um die y-Achse also von winkel (0, 0, 0) bis (0, 359, 0) in 8 Sekunden
44#drehtellerSlide = vrRotationSlide(drehteller, 0, 0, 0, 0, 359, 0, 8.0)
45
46# Mann kann auch eine Achse angeben um die gedreht wird
47# also (0.5, 0, 0.5) ist der erste Punkt der Achse und (0.5, 1, 0.5) der
48# zweite Punkt der Achse und dann der winkel von 0 - 359.
49rotateSlide = vrRotationAxisSlide(scene, 0.5, 0, 0.5,   0.5, 1, 0.5,  0, 359, 8.0)
50sceneRotate.add(rotateSlide)
51
52# define speech input command rotate
53speechRotate = vrSpeech("rotate")
54speechRotate.connect(sceneRotate, SWITCH_TOGGLE)
55vrLogWarning("Say rotate to toggle rotation of the scene")
56
57# define key r to rotate scene
58keyR = vrKey(Key_R)
59keyR.connect(sceneRotate, SWITCH_TOGGLE)
60vrLogWarning("press key r to toggle rotation of the scene")
61
62# wackel
63
64sceneWiggle = vrInterpolator()
65
66# turns around the y-axis (0-359 degrees) in 8 seconds
67#drehtellerSlide = vrRotationSlide(drehteller, 0, 0, 0, 0, 359, 0, 8.0)
68
69# You can also specify an axis to turn around
70# (0.5, 0, 0.5) is the first point on the axis and (0.5, 1, 0.5) is
71# the second point and later the start and stop angle
72rotateSlide2 = vrRotationAxisSlide(scene, 0.5, 0, 0.5,   0.5, 1, 0.5,  0, 2, 0.5)
73rotateSlide3 = vrRotationAxisSlide(scene, 0.5, 0, 0.5,   0.5, 1, 0.5,  2, 0, 0.5)
74sceneWiggle.add(rotateSlide2)
75sceneWiggle.add(rotateSlide3)
76
77# define speech input command wiggle
78speechWiggle = vrSpeech("wiggle")
79speechWiggle.connect(sceneWiggle, SWITCH_TOGGLE)
80vrLogWarning("Say wiggle to wiggle the scene")
81
82# define key w to wiggle the scene
83keyW = vrKey(Key_W)
84keyW.connect(sceneWiggle, SWITCH_TOGGLE)
85vrLogWarning("press key w to wiggle the scene")