Search code examples
google-cloud-platformgoogle-speech-api

Google cloud speech to text API - text output contains spaces or hyphens


In the Google cloud speech to text API whenever the user speaks the number or read out the number like 9500456765 the converted text that comes out is 9500 456 765.

There are spaces in between the numbers or even hyphens like 9500-456-765.

Is there a way to get the number same as the user had spoken without any spaces or hyphens?


Solution

  • You cannot tell speech API to disable this splitting of numbers. What you can do is to detect this in text and post process the text output to remove these spaces and hyphens. What I do in python when result is number is this,

    result.replace(' ','').replace('-','')