Mercurial > code > home > repos > homeauto
annotate service/speechMusic/speechMusic.py @ 1257:c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
Ignore-this: 28a41741b1f33114348f5ec6e7b4bef9
darcs-hash:0c6f5acce103b7a9f999fa729ef5e3c7c0d1171a
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Fri, 19 Apr 2019 13:51:54 -0700 |
parents | a723efcf6476 |
children | 7e09c0d0a86e |
rev | line source |
---|---|
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
1 #!bin/python |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
2 """ |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
3 play sounds according to POST requests. |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
4 """ |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
5 from __future__ import division |
1164
1fe67fedf5ac
move speech_music into docker and into pygame
drewp <drewp@bigasterisk.com>
parents:
1020
diff
changeset
|
6 import sys, tempfile |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
7 from pyjade.ext.mako import preprocessor as mako_preprocessor |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
8 from mako.lookup import TemplateLookup |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
9 from twisted.internet import reactor |
1257
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
10 from cyclone.httpclient import fetch |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
11 from generator import tts |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
12 import xml.etree.ElementTree as ET |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
13 from klein import Klein |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
14 from twisted.web.static import File |
1164
1fe67fedf5ac
move speech_music into docker and into pygame
drewp <drewp@bigasterisk.com>
parents:
1020
diff
changeset
|
15 from logsetup import log |
1fe67fedf5ac
move speech_music into docker and into pygame
drewp <drewp@bigasterisk.com>
parents:
1020
diff
changeset
|
16 import pygame.mixer |
1257
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
17 class URIRef(str): pass |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
18 |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
19 templates = TemplateLookup(directories=['.'], |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
20 preprocessor=mako_preprocessor, |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
21 filesystem_checks=True) |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
22 |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
23 def makeSpeech(speech, fast=False): |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
24 speechWav = tempfile.NamedTemporaryFile(suffix='.wav') |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
25 |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
26 root = ET.Element("SABLE") |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
27 r = ET.SubElement(root, "RATE", |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
28 attrib=dict(SPEED="+50%" if fast else "+0%")) |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
29 for sentence in speech.split('.'): |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
30 div = ET.SubElement(r, "DIV") |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
31 div.set("TYPE", "sentence") |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
32 div.text = sentence |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
33 |
1257
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
34 speechSecs = tts(speech, speechWav.name) |
1164
1fe67fedf5ac
move speech_music into docker and into pygame
drewp <drewp@bigasterisk.com>
parents:
1020
diff
changeset
|
35 return pygame.mixer.Sound(speechWav.name), speechSecs |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
36 |
1257
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
37 class LOADING(object): pass |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
38 |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
39 class SoundEffects(object): |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
40 def __init__(self): |
1257
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
41 self.buffers = {} # URIRef : pygame.mixer.Sound |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
42 self.playingSources = [] |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
43 self.queued = [] |
1256
a723efcf6476
WIP updating to read sounds from http
drewp <drewp@bigasterisk.com>
parents:
1164
diff
changeset
|
44 self.volume = 1 # level for the next sound that's played (or existing instances of the same sound) |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
45 |
1257
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
46 def _getSound(self, uri): |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
47 def done(resp): |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
48 print('got', len(resp.body)) |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
49 |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
50 return fetch(uri).addCallback(done) |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
51 |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
52 def playEffect(self, uri): |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
53 if uri not in self.buffers: |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
54 self.buffers[uri] = LOADING |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
55 self._getSound(uri).addCallback(self.playEffect, uri) |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
56 if self.buffers[uri] is LOADING: |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
57 # The first playback loads then plays, but any attempts |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
58 # during that load are dropped, not queued. |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
59 return |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
60 snd = self.buffers[uri] |
1256
a723efcf6476
WIP updating to read sounds from http
drewp <drewp@bigasterisk.com>
parents:
1164
diff
changeset
|
61 snd.set_volume(self.volume) |
a723efcf6476
WIP updating to read sounds from http
drewp <drewp@bigasterisk.com>
parents:
1164
diff
changeset
|
62 return self.playBuffer(snd) |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
63 |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
64 def playSpeech(self, txt, preEffect=None, postEffect=None, preEffectOverlap=0): |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
65 buf, secs = makeSpeech(txt) |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
66 t = 0 |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
67 if preEffect: |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
68 t += self.playEffect(preEffect) |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
69 t -= preEffectOverlap |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
70 |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
71 reactor.callLater(t, self.playBuffer, buf) |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
72 t += secs |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
73 |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
74 if postEffect: |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
75 self.playBufferLater(t, self.buffers[postEffect]) |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
76 |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
77 def playBufferLater(self, t, buf): |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
78 self.queued.append(reactor.callLater(t, self.playBuffer, buf)) |
813
d17164dbd15f
speechMusic: don't fail on missing 'name' attr
drewp <drewp@bigasterisk.com>
parents:
809
diff
changeset
|
79 |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
80 def playBuffer(self, buf): |
1164
1fe67fedf5ac
move speech_music into docker and into pygame
drewp <drewp@bigasterisk.com>
parents:
1020
diff
changeset
|
81 buf.play() |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
82 |
1164
1fe67fedf5ac
move speech_music into docker and into pygame
drewp <drewp@bigasterisk.com>
parents:
1020
diff
changeset
|
83 secs = buf.get_length() |
1fe67fedf5ac
move speech_music into docker and into pygame
drewp <drewp@bigasterisk.com>
parents:
1020
diff
changeset
|
84 self.playingSources.append(buf) |
1fe67fedf5ac
move speech_music into docker and into pygame
drewp <drewp@bigasterisk.com>
parents:
1020
diff
changeset
|
85 reactor.callLater(secs + .1, self.done, buf) |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
86 return secs |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
87 |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
88 def done(self, src): |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
89 try: |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
90 self.playingSources.remove(src) |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
91 except ValueError: |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
92 pass |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
93 |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
94 def stopAll(self): |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
95 while self.playingSources: |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
96 self.playingSources.pop().stop() |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
97 for q in self.queued: |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
98 q.cancel() |
1257
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
99 # doesn't cover the callLater ones |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
100 |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
101 class Server(object): |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
102 app = Klein() |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
103 def __init__(self, sfx): |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
104 self.sfx = sfx |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
105 |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
106 @app.route('/static/', branch=True) |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
107 def static(self, request): |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
108 return File("./static") |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
109 |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
110 @app.route('/', methods=['GET']) |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
111 def index(self, request): |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
112 t = templates.get_template("index.jade") |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
113 return t.render(effectNames=[ |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
114 dict(name=k, postUri='effects/%s' % k) |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
115 for k in self.sfx.buffers.keys()]) |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
116 |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
117 @app.route('/speak', methods=['POST']) |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
118 def speak(self, request): |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
119 self.sfx.playSpeech(request.args['msg'][0]) |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
120 return "ok" |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
121 |
1256
a723efcf6476
WIP updating to read sounds from http
drewp <drewp@bigasterisk.com>
parents:
1164
diff
changeset
|
122 @app.route('/playSound', methods=['POST']) |
a723efcf6476
WIP updating to read sounds from http
drewp <drewp@bigasterisk.com>
parents:
1164
diff
changeset
|
123 def effect(self, request): |
a723efcf6476
WIP updating to read sounds from http
drewp <drewp@bigasterisk.com>
parents:
1164
diff
changeset
|
124 uri = request.args['uri'][0] |
a723efcf6476
WIP updating to read sounds from http
drewp <drewp@bigasterisk.com>
parents:
1164
diff
changeset
|
125 self.sfx.playEffect(uri) |
a723efcf6476
WIP updating to read sounds from http
drewp <drewp@bigasterisk.com>
parents:
1164
diff
changeset
|
126 return "ok" |
a723efcf6476
WIP updating to read sounds from http
drewp <drewp@bigasterisk.com>
parents:
1164
diff
changeset
|
127 |
a723efcf6476
WIP updating to read sounds from http
drewp <drewp@bigasterisk.com>
parents:
1164
diff
changeset
|
128 @app.route('/volume', methods=['PUT']) |
1257
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
129 def volume(self, request, name): |
c0721332a9fe
WIP speechmusic to load from http, but pulseaudio out is broken
drewp <drewp@bigasterisk.com>
parents:
1256
diff
changeset
|
130 self.sfx.setVolume(float(request.args['v'][0])) |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
131 return "ok" |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
132 |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
133 @app.route('/stopAll', methods=['POST']) |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
134 def stopAll(self, request): |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
135 self.sfx.stopAll() |
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
136 return "ok" |
1164
1fe67fedf5ac
move speech_music into docker and into pygame
drewp <drewp@bigasterisk.com>
parents:
1020
diff
changeset
|
137 |
1fe67fedf5ac
move speech_music into docker and into pygame
drewp <drewp@bigasterisk.com>
parents:
1020
diff
changeset
|
138 pygame.mixer.init() |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
139 sfx = SoundEffects() |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
140 |
880
89e37684b362
big rewrite of speechMusic to use klein and openal
drewp <drewp@bigasterisk.com>
parents:
841
diff
changeset
|
141 server = Server(sfx) |
1164
1fe67fedf5ac
move speech_music into docker and into pygame
drewp <drewp@bigasterisk.com>
parents:
1020
diff
changeset
|
142 server.app.run(endpoint_description=r"tcp6:port=9049:interface=\:\:") |