In [1]:
import warnings
warnings.filterwarnings('ignore')
import os
import sys
import string
import glob
import re
import itertools
import hashlib
from collections import Counter

import scipy as sp
import numpy as np
import pandas as pd

import audiotools

import plotly.plotly as py
import plotly.tools as tls
import plotly.graph_objs as go
import cufflinks as cf
cf.set_config_file(offline=False, world_readable=True, theme='pearl')
tls.set_credentials_file(username=os.environ.get('PLOTLY_USERNAME'),
                         api_key=os.environ.get('PLOTLY_APIKEY'))

import matplotlib.pyplot as plt
import matplotlib
%matplotlib inline

import seaborn as sns
sns.set_context("notebook",
                font_scale=1.5,
                rc={"lines.linewidth": 2.5})

In [2]:
credentials = {
    "url": "https://stream.watsonplatform.net/speech-to-text/api",
    "password": "5sg4fVm1Ac1c",
    "username": "5951abee-dfba-4bc5-8039-8e6612a79c5a"
}

In [3]:
datadir = '/home/kcavagnolo/speech/data/'
files = ['kendra', 'kendra_slow', 'kendra_fast']

for f in files:
    infile = datadir+f+'.wav'
    outfile = datadir+f+'.flac'
    audiotools.open(infile).convert(outfile, audiotools.FlacAudio)

In [6]:
%%bash curl -X POST -u "5951abee-dfba-4bc5-8039-8e6612a79c5a":"5sg4fVm1Ac1c" \
    --header "Content-Type: audio/flac" \
    --header "Transfer-Encoding: chunked" \
    --data-binary @/home/kcavagnolo/speech/data/kendra_fast.flac \
    "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize"


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-5e6ec2513176> in <module>()
----> 1 get_ipython().run_cell_magic(u'bash', u'curl -X POST -u "5951abee-dfba-4bc5-8039-8e6612a79c5a":"5sg4fVm1Ac1c" \\', u'    --header "Content-Type: audio/flac" \\\n    --header "Transfer-Encoding: chunked" \\\n    --data-binary @/home/kcavagnolo/speech/data/kendra_fast.flac \\\n    "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize"')

/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
   2291             magic_arg_s = self.var_expand(line, stack_depth)
   2292             with self.builtin_trap:
-> 2293                 result = fn(magic_arg_s, cell)
   2294             return result
   2295 

/usr/local/lib/python2.7/dist-packages/IPython/core/magics/script.pyc in named_script_magic(line, cell)
    145             else:
    146                 line = script
--> 147             return self.shebang(line, cell)
    148 
    149         # write a basic docstring:

<decorator-gen-108> in shebang(self, line, cell)

/usr/local/lib/python2.7/dist-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
    191     # but it's overkill for just that one bit of state.
    192     def magic_deco(arg):
--> 193         call = lambda f, *a, **k: f(*a, **k)
    194 
    195         if callable(arg):

/usr/local/lib/python2.7/dist-packages/IPython/core/magics/script.pyc in shebang(self, line, cell)
    181             3
    182         """
--> 183         argv = arg_split(line, posix = not sys.platform.startswith('win'))
    184         args, cmd = self.shebang.parser.parse_known_args(argv)
    185 

/usr/local/lib/python2.7/dist-packages/IPython/utils/_process_common.pyc in arg_split(s, posix, strict)
    200     while True:
    201         try:
--> 202             tokens.append(next(lex))
    203         except StopIteration:
    204             break

/usr/lib/python2.7/shlex.pyc in next(self)
    267 
    268     def next(self):
--> 269         token = self.get_token()
    270         if token == self.eof:
    271             raise StopIteration

/usr/lib/python2.7/shlex.pyc in get_token(self)
     94             return tok
     95         # No pushback.  Get a token.
---> 96         raw = self.read_token()
     97         # Handle inclusions
     98         if self.source is not None:

/usr/lib/python2.7/shlex.pyc in read_token(self)
    189                         print "shlex: I see EOF in escape state"
    190                     # XXX what error should be raised here?
--> 191                     raise ValueError, "No escaped character"
    192                 # In posix shells, only the quote itself or the escape
    193                 # character may be escaped within quotes.

ValueError: No escaped character

In [ ]: