0

I receive this error when trying to use IBM Watson. Maybe someone has the same problem - or even better - a solution?


    Traceback (most recent call last):
      File "MY FILE.py", line 27, in 
        service.recognize(
      File "C:\Users\...\lib\site-packages\ibm_watson\speech_to_text_v1.py", line 566, in recognize
        response = self.send(request)
      File "C:\Users\....\lib\site-packages\ibm_cloud_sdk_core\base_service.py", line 308, in send
    raise ApiException(response.status_code, http_response=response)
    ibm_cloud_sdk_core.api_exception.ApiException: Error: 
    Internal Server Error
    Internal Server Error - Write
    The server encountered an internal error or misconfiguration and was unable to
    complete your request.

Reference #4.a54a0760.1627114991.5298a594 , Code: 503

Here is the code I am using


    # Accepts only .mp3 Format of Audio
    # File 
      
       
    import json
    from os.path import join, dirname
    from ibm_watson import SpeechToTextV1
    from ibm_watson.websocket import RecognizeCallback, AudioSource
    from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
      
       
    # Insert API Key in place of 
    # YOUR UNIQUE API KEY - I replaced this text with my API KEY in actual code
    authenticator = IAMAuthenticator('YOUR UNIQUE API KEY') 
    service = SpeechToTextV1(authenticator = authenticator)
       
    #Insert URL in place of API_URL - below is actual I am using
    service.set_service_url('https://api.us-east.speech-to-text.watson.cloud.ibm.com')
       
    # Insert local mp3 file path in
    # place of LOCAL FILE PATH - I am using my C drive and replaced actual file path ending 
    with open(join(dirname('__file__'), r'C:/Users/LOCAL FILE PATH.mp3'), 
          'rb') as audio_file:
      
        dic = json.loads(
                json.dumps(
                    service.recognize(
                        audio=audio_file,
                        content_type='audio/flac',   
                        model='en-US_NarrowbandModel',
                    continuous=True).get_result(), indent=2))
      
    # Stores the transcribed text
    str = ""
      
    while bool(dic.get('results')):
         str = dic.get('results').pop().get('alternatives').pop().get('transcript')+str[:]
       
    print(str)

  • if it is `Internal Server Error` then you should ask IBM admins for help - it can be temporary problem with server and only admins has access to servers. – furas Jul 24 '21 at 17:15
  • you read file `.mp3` but you send it as `'audio/flac'` - it can make conflict. It should be `'audio/mp3'`. See other [ContentType](http://watson-developer-cloud.github.io/node-sdk/master/enums/speechtotextv1.addaudioconstants.contenttype.html) – furas Jul 24 '21 at 17:20
  • @furas 1) Thanks, the 'audio/mp3' vs 'audio/flac' made no difference, same error as above. 2) IBM admins; it's been two days like this, but maybe I will try that next, if I find a support channel they react to...:) – LakeConstanceCH Jul 24 '21 at 17:24
  • if you find example code in documentation and it will give the error then for sure problem is server and you can't fix it - only admins may help. – furas Jul 24 '21 at 18:09

1 Answers1

0

Solution provided by IBM engineer worked; "Your code is using the URL of our US-East datacenter and it's recommended to include your instance ID in the URL." Adding URL .../instance/MY ID solved problem!