title: Is there a way to force Google Speech api to return only words as response?
body: <p>I am using Googles this api :-</p>
  
  <blockquote>
    <p><a href="https://www.google.com/speech-api/v2/recognize?output=json&amp;lang=" rel="noreferrer">https://www.google.com/speech-api/v2/recognize?output=json&amp;lang=</a>"+
    language_code+"&amp;key="My key"</p>
  </blockquote>
  
  <p>for speech recognition and it's working very well.</p>
  
  <p>The issue is with numbers i.e, if I say <code>one two three four</code> the result will be  <code>1234</code>
  and if I say <code>one thousand two hundred thirty four</code> the result is still <code>1234</code>. </p>
  
  <p>Another issue is that with other languages i.e. the word <code>elf</code> in German is <code>eleven</code>. If you say <code>elf</code> the result is <code>11</code>, instead of elf.</p>
  
  <p>I know we have no control over the api but is there any parameters or hacks we can add to this api to force it to return only words.</p>
  
  <p>The response some times have the correct result but not always.</p>
  
  <p>These are sample responses</p>
  
  <p>1) When I say "one two three four"</p>
  
  <pre><code>{"result":[{"alternative":[{"transcript":"1234","confidence":0.47215959},{"transcript":"1 2 3 4","confidence":0.25},{"transcript":"one two three four","confidence":0.25},{"transcript":"1 2 34","confidence":0.33333334},{"transcript":"1 to 34","confidence":1}],"final":true}],"result_index":0}
  </code></pre>
  
  <p>2) When I say "one thousand two hundred thirty four"</p>
  
  <pre><code>{"result":[{"alternative":[{"transcript":"1234","confidence":0.94247383},{"transcript":"1.254","confidence":1},{"transcript":"1284","confidence":1},{"transcript":"1244","confidence":1},{"transcript":"1230 4","confidence":1}],"final":true}],"result_index":0}
  </code></pre>
  
  <p>What I have done. </p>
  
  <p>Check if the result is a number, Then split each number by space and check if there is same sequence in the result array. In this e.g.  Result 1234 becomes 1 2 3 4  and will search if there is a similar sequence in the result array and then convert it to words.In  2nd case there is no 1 2 3 4 so will stick with the original result.</p>
  
  <p>This is the code.</p>
  
  <pre><code> String numberPattern = "[0-9]";
    Pattern r1 = Pattern.compile(numberPattern);
    Matcher m2 = r1.matcher(output);
    if (m2.find()) {
        char[] digits2 = output.toCharArray();
        String digit = "";
        for (char c: digits2) {
            digit += c + " ";
        }
  
        for (int i = 1; i &lt; jsonArray2.length(); i++) {
            String value = jsonArray2.getJSONObject(i).getString("transcript");
            if (digit.trim().equals(value.trim())) {
                output = digit + " ";
            }
        }
    }
  </code></pre>
  
  <p>So the issue is when I "say thirteen four eight" this method will split 13 as one three and hence not a reliable solution.</p>
  
  <p><strong>Update</strong></p>
  
  <p>I tried the new cloud vision api (<a href="https://cloud.google.com/speech/" rel="noreferrer">https://cloud.google.com/speech/</a>) and it's little better than the v2. The result for <code>one two three four</code> is in words itself for which my workaround is working as well. But when I say <code>thirteen four eight</code> it's still the same result as in v2.</p>
  
  <p>And also elf is still 11 in German. </p>
  
  <p>Also tried <code>speech_context</code> that also didn't worked.</p>