Skip to content

Instantly share code, notes, and snippets.

@app.route('/recording', methods=['POST'])
def alexa_task():
file = request.files['file']
filename = str(file.filename)
file.save('current_data/' + file.filename)
reply = {'msg': 'Success'}
sox_command = 'sox -r 16000 -e unsigned -b 16 -c 1 current_data/%s current_data/%s.wav' % (
filename, filename[:-4])
os.system(sox_command)
with open('current_file.text', 'w+') as f:
@app.route('/recording', methods=['POST'])
def alexa_task():
file = request.files['file']
filename = str(file.filename)
file.save('current_data/' + file.filename)
reply = {'msg': 'Success'}
sox_command = 'sox -r 16000 -e unsigned -b 16 -c 1 %s %s.wav' % (
filename, filename[:-4])
os.system(sox_command)
with open('current_file.text', 'w+') as f:
with open(tmp_path + 'recording.wav') as inf:
files = [
('file', ('request', json.dumps(data), 'application/json; charset=UTF-8')),
('file', ('audio', inf, 'audio/L16; rate=16000; channels=1'))
]
resp = requests.post(url, headers=headers, files=files)
with open(tmp_path + 'recording.wav') as inf:
files = [
('file', ('request', json.dumps(data), 'application/json; charset=UTF-8')),
('file', ('audio', inf, 'audio/L16; rate=16000; channels=1'))
]
resp = requests.post(url, headers=headers, files=files)
resp_copy = requests.post('http://speech-analysis-server-ip-address/recording', files=[files[1]])
@app.route('/textfile', methods=['POST'])
def transcipt():
data = json.loads(request.data)
text = str(data['text'])
text = text.upper()
with open('current_file.text', 'r') as f:
filename = f.read()
with open('/tmp/random_folder/' + filename + '.lab', 'w+') as f:
f.write(text)
os.system('mv current_data/%s.wav /tmp/random_folder/' % filename)
import os
from flask import Flask, request
from flask_ask import Ask, statement, question, session
import json
import requests
basedir = os.path.abspath(os.path.dirname(__file__))
app = Flask(__name__)
ask = Ask(app, "/")
# -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2017-03-29 18:34
from __future__ import unicode_literals
from django.db import migrations, models
import uuid
from django.db.models.signals import post_save
from core.hooks.allocation_source import (
listen_for_allocation_threshold_met,
# -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2017-03-29 18:34
from __future__ import unicode_literals
from django.db import migrations, models
import uuid
from django.db.models.signals import post_save
from django.db.models.query import Q
from core.hooks.allocation_source import (
# DATA PROVIDED TO US. STRUCTURE CANNOT BE MODIFIED! WELCOME TO THE REAL WORLD PRINCESS
sizes = [
{
"name": "item_1",
"size_in_mL": "100mL",
"alternate_identifier": "axc45"
},
{
"name": "item_2",