Google speech to text API result is empty










0















I am using Cloud speech to text api to convert audio file to text file. I am executing it using python, Below is code.



import io
import os

os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="D:\Sentiment_Analysis\My Project 59503-717155d6fb4a.json"

# Imports the Google Cloud client library
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types

# Instantiates a client
client = speech.SpeechClient()

# The name of the audio file to transcribe
file_name = os.path.join(os.path.dirname('D:CallADoc_VoiceImplementationaudioclip154173607416598.amr'),'CallADoc_VoiceImplementation','audioclip154173607416598.amr')

# Loads the audio into memory
with io.open(file_name, 'rb') as audio_file: content = audio_file.read()
audio = types.RecognitionAudio(content=content)

config = types.RecognitionConfig(encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,sample_rate_hertz=16000,language_code='en-IN')

# Detects speech in the audio file
response = client.recognize(config, audio)

for result in response.results: print('Transcript: '.format(result.alternatives[0].transcript))


When i execute the sample/tested audio file in the name "audio.raw", the audio is converting and result is like below.



runfile('C:/Users/sandesh.p/CallADoc/GoogleSpeechtoText.py', wdir='C:/Users/sandesh.p/CallADoc')
Transcript: how old is the Brooklyn Bridge


But for same code, i am recording a audio and try to convert, it is giving empty result like below:



runfile('C:/Users/sandesh.p/CallADoc/GoogleSpeechtoText.py', wdir='C:/Users/sandesh.p/CallADoc')


I am trying to fix this from past 2 days and please help me to resolve this.










share|improve this question
























  • Have you tried to follow the troubleshooting steps to have your audio with the appropriate settings?

    – F10
    Nov 13 '18 at 20:19











  • Thanks for the reply, I have fixed it now by following troubleshooting steps.

    – Sandesh Puttaraj
    Nov 14 '18 at 6:06











  • Good! I'll put it as an answer so you can mark it.

    – F10
    Nov 14 '18 at 13:07















0















I am using Cloud speech to text api to convert audio file to text file. I am executing it using python, Below is code.



import io
import os

os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="D:\Sentiment_Analysis\My Project 59503-717155d6fb4a.json"

# Imports the Google Cloud client library
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types

# Instantiates a client
client = speech.SpeechClient()

# The name of the audio file to transcribe
file_name = os.path.join(os.path.dirname('D:CallADoc_VoiceImplementationaudioclip154173607416598.amr'),'CallADoc_VoiceImplementation','audioclip154173607416598.amr')

# Loads the audio into memory
with io.open(file_name, 'rb') as audio_file: content = audio_file.read()
audio = types.RecognitionAudio(content=content)

config = types.RecognitionConfig(encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,sample_rate_hertz=16000,language_code='en-IN')

# Detects speech in the audio file
response = client.recognize(config, audio)

for result in response.results: print('Transcript: '.format(result.alternatives[0].transcript))


When i execute the sample/tested audio file in the name "audio.raw", the audio is converting and result is like below.



runfile('C:/Users/sandesh.p/CallADoc/GoogleSpeechtoText.py', wdir='C:/Users/sandesh.p/CallADoc')
Transcript: how old is the Brooklyn Bridge


But for same code, i am recording a audio and try to convert, it is giving empty result like below:



runfile('C:/Users/sandesh.p/CallADoc/GoogleSpeechtoText.py', wdir='C:/Users/sandesh.p/CallADoc')


I am trying to fix this from past 2 days and please help me to resolve this.










share|improve this question
























  • Have you tried to follow the troubleshooting steps to have your audio with the appropriate settings?

    – F10
    Nov 13 '18 at 20:19











  • Thanks for the reply, I have fixed it now by following troubleshooting steps.

    – Sandesh Puttaraj
    Nov 14 '18 at 6:06











  • Good! I'll put it as an answer so you can mark it.

    – F10
    Nov 14 '18 at 13:07













0












0








0








I am using Cloud speech to text api to convert audio file to text file. I am executing it using python, Below is code.



import io
import os

os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="D:\Sentiment_Analysis\My Project 59503-717155d6fb4a.json"

# Imports the Google Cloud client library
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types

# Instantiates a client
client = speech.SpeechClient()

# The name of the audio file to transcribe
file_name = os.path.join(os.path.dirname('D:CallADoc_VoiceImplementationaudioclip154173607416598.amr'),'CallADoc_VoiceImplementation','audioclip154173607416598.amr')

# Loads the audio into memory
with io.open(file_name, 'rb') as audio_file: content = audio_file.read()
audio = types.RecognitionAudio(content=content)

config = types.RecognitionConfig(encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,sample_rate_hertz=16000,language_code='en-IN')

# Detects speech in the audio file
response = client.recognize(config, audio)

for result in response.results: print('Transcript: '.format(result.alternatives[0].transcript))


When i execute the sample/tested audio file in the name "audio.raw", the audio is converting and result is like below.



runfile('C:/Users/sandesh.p/CallADoc/GoogleSpeechtoText.py', wdir='C:/Users/sandesh.p/CallADoc')
Transcript: how old is the Brooklyn Bridge


But for same code, i am recording a audio and try to convert, it is giving empty result like below:



runfile('C:/Users/sandesh.p/CallADoc/GoogleSpeechtoText.py', wdir='C:/Users/sandesh.p/CallADoc')


I am trying to fix this from past 2 days and please help me to resolve this.










share|improve this question
















I am using Cloud speech to text api to convert audio file to text file. I am executing it using python, Below is code.



import io
import os

os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="D:\Sentiment_Analysis\My Project 59503-717155d6fb4a.json"

# Imports the Google Cloud client library
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types

# Instantiates a client
client = speech.SpeechClient()

# The name of the audio file to transcribe
file_name = os.path.join(os.path.dirname('D:CallADoc_VoiceImplementationaudioclip154173607416598.amr'),'CallADoc_VoiceImplementation','audioclip154173607416598.amr')

# Loads the audio into memory
with io.open(file_name, 'rb') as audio_file: content = audio_file.read()
audio = types.RecognitionAudio(content=content)

config = types.RecognitionConfig(encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,sample_rate_hertz=16000,language_code='en-IN')

# Detects speech in the audio file
response = client.recognize(config, audio)

for result in response.results: print('Transcript: '.format(result.alternatives[0].transcript))


When i execute the sample/tested audio file in the name "audio.raw", the audio is converting and result is like below.



runfile('C:/Users/sandesh.p/CallADoc/GoogleSpeechtoText.py', wdir='C:/Users/sandesh.p/CallADoc')
Transcript: how old is the Brooklyn Bridge


But for same code, i am recording a audio and try to convert, it is giving empty result like below:



runfile('C:/Users/sandesh.p/CallADoc/GoogleSpeechtoText.py', wdir='C:/Users/sandesh.p/CallADoc')


I am trying to fix this from past 2 days and please help me to resolve this.







python google-api speech-recognition google-cloud-speech






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 8:27









DaImTo

43.2k1058236




43.2k1058236










asked Nov 13 '18 at 5:09









Sandesh PuttarajSandesh Puttaraj

118213




118213












  • Have you tried to follow the troubleshooting steps to have your audio with the appropriate settings?

    – F10
    Nov 13 '18 at 20:19











  • Thanks for the reply, I have fixed it now by following troubleshooting steps.

    – Sandesh Puttaraj
    Nov 14 '18 at 6:06











  • Good! I'll put it as an answer so you can mark it.

    – F10
    Nov 14 '18 at 13:07

















  • Have you tried to follow the troubleshooting steps to have your audio with the appropriate settings?

    – F10
    Nov 13 '18 at 20:19











  • Thanks for the reply, I have fixed it now by following troubleshooting steps.

    – Sandesh Puttaraj
    Nov 14 '18 at 6:06











  • Good! I'll put it as an answer so you can mark it.

    – F10
    Nov 14 '18 at 13:07
















Have you tried to follow the troubleshooting steps to have your audio with the appropriate settings?

– F10
Nov 13 '18 at 20:19





Have you tried to follow the troubleshooting steps to have your audio with the appropriate settings?

– F10
Nov 13 '18 at 20:19













Thanks for the reply, I have fixed it now by following troubleshooting steps.

– Sandesh Puttaraj
Nov 14 '18 at 6:06





Thanks for the reply, I have fixed it now by following troubleshooting steps.

– Sandesh Puttaraj
Nov 14 '18 at 6:06













Good! I'll put it as an answer so you can mark it.

– F10
Nov 14 '18 at 13:07





Good! I'll put it as an answer so you can mark it.

– F10
Nov 14 '18 at 13:07












1 Answer
1






active

oldest

votes


















1














Try following the troubleshooting steps to have your audio with the appropriate settings.



For instance, your audio file will have the following settings, which are required to have better results:



Encoding: FLAC
Channels: 1 @ 16-bit
Sampleratehertz: 16000Hz





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274198%2fgoogle-speech-to-text-api-result-is-empty%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Try following the troubleshooting steps to have your audio with the appropriate settings.



    For instance, your audio file will have the following settings, which are required to have better results:



    Encoding: FLAC
    Channels: 1 @ 16-bit
    Sampleratehertz: 16000Hz





    share|improve this answer



























      1














      Try following the troubleshooting steps to have your audio with the appropriate settings.



      For instance, your audio file will have the following settings, which are required to have better results:



      Encoding: FLAC
      Channels: 1 @ 16-bit
      Sampleratehertz: 16000Hz





      share|improve this answer

























        1












        1








        1







        Try following the troubleshooting steps to have your audio with the appropriate settings.



        For instance, your audio file will have the following settings, which are required to have better results:



        Encoding: FLAC
        Channels: 1 @ 16-bit
        Sampleratehertz: 16000Hz





        share|improve this answer













        Try following the troubleshooting steps to have your audio with the appropriate settings.



        For instance, your audio file will have the following settings, which are required to have better results:



        Encoding: FLAC
        Channels: 1 @ 16-bit
        Sampleratehertz: 16000Hz






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 13:12









        F10F10

        1,2762414




        1,2762414



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274198%2fgoogle-speech-to-text-api-result-is-empty%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Barbados

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3