Spaces:
Runtime error
Runtime error
Commit
·
987011f
1
Parent(s):
5982fd5
fixed bugs in app code
Browse files
app.py
CHANGED
|
@@ -17,17 +17,21 @@ def process_audio(audio, state=collections.defaultdict(partial(collections.deque
|
|
| 17 |
data = scipy.signal.resample(audio[1], int(float(audio[1].shape[0])/audio[0]*16000))
|
| 18 |
|
| 19 |
# Get predictions
|
| 20 |
-
for i in range(0,
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
prediction = model.predict(chunk)
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
# Make line plot
|
| 33 |
dfs = []
|
|
@@ -68,6 +72,8 @@ you should see a spike in the score for a given model after speaking a related w
|
|
| 68 |
| --- | --- |
|
| 69 |
| alexa | "alexa" |
|
| 70 |
| hey_mycroft | "hey mycroft"|
|
|
|
|
|
|
|
| 71 |
| weather | "what's the weather", "tell me today's weather" |
|
| 72 |
| x_minute_timer | "set a timer for 1 minute", "create 1 hour alarm" |
|
| 73 |
|
|
|
|
| 17 |
data = scipy.signal.resample(audio[1], int(float(audio[1].shape[0])/audio[0]*16000))
|
| 18 |
|
| 19 |
# Get predictions
|
| 20 |
+
for i in range(0, data.shape[0], 1280):
|
| 21 |
+
if len(data.shape) == 2 or data.shape[-1] == 2:
|
| 22 |
+
chunk = data[i:i+1280][:, 0] # just get one channel of audio
|
| 23 |
+
else:
|
| 24 |
+
chunk = data[i:i+1280]
|
| 25 |
+
|
| 26 |
+
if chunk.shape[0] == 1280:
|
| 27 |
prediction = model.predict(chunk)
|
| 28 |
+
for key in prediction:
|
| 29 |
+
#Fill deque with zeros if it's empty
|
| 30 |
+
if len(state[key]) == 0:
|
| 31 |
+
state[key].extend(np.zeros(60))
|
| 32 |
+
|
| 33 |
+
# Add prediction
|
| 34 |
+
state[key].append(prediction[key])
|
| 35 |
|
| 36 |
# Make line plot
|
| 37 |
dfs = []
|
|
|
|
| 72 |
| --- | --- |
|
| 73 |
| alexa | "alexa" |
|
| 74 |
| hey_mycroft | "hey mycroft"|
|
| 75 |
+
| hey_jarvis | "hey jarvis"|
|
| 76 |
+
| hey_rhasspy | "hey rhasspy"|
|
| 77 |
| weather | "what's the weather", "tell me today's weather" |
|
| 78 |
| x_minute_timer | "set a timer for 1 minute", "create 1 hour alarm" |
|
| 79 |
|