Voicemail Transcription via IBM Watson Speech to Text--issues after user/passwords removed in IBM Cloud [SOLVED]

Using FreePBX 13/Asterisk 13

At issue is getting voicemail transcription into emails using the IBM Watson speech to text engine utilizing the apikey. I’ve noted that @kristiandg had the same question, but that thread is closed.

I’ve had the IBM Watson script working in the past when watson allowed the creation of a username and password following a freepbx blog post.

I’m trying to get the apikey method working using the script that Ward Mundy adjusted for the change by ibm, but it is not working.

Do I need to alter extensions_custom.conf as noted by Jerson? I don’t believe I’ve had to do this in the past, and the nerdvittles post with the altered ascript using apikey doesn’t mention this.

Has anyone had any luck getting the new script working? The only other thought I had is that ward’s script perhaps requires sendmail, whereas my server has postfix smtp server installed.

In general, code like this is going to be in extensions_custom.conf, so modifying that it very likely to be required.

Do you have any idea what isn’t working?

To follow up on this, you have also made the needed changes with your account on the IBM Cloud side right? They changed how the Free Tiers work a few months back, they are no longer “Life Long” with a monthly limit, they are 30 days and then you need to move to a paid tier (still pay-as-you-use).

Yeah, my IBM account is on the standard plan for Watson, not the free tier.

No idea;

If I run a test while running tail -f /var/log/maillog

  • I do get output if I do not have the bash script enterend in the Mail Command field.
  • I do not get output if the bash script, /usr/local/sbin/sendmailmp3 is entered in the Mail Command Field.

I’ve checked the history of the PBXs that I’ve had in the past, the only difference is the field for user/password vs. API Key.

There is something about Ward’s script that does not jive well (given that it’s for incredible pbx/piaf, there are enough differences that I’m not too surprised that it doesn’t quite work).

I’ve modified the script from https://www.freepbxhosting.com/blog/howto-adventures-in-voicemail-transcripts/ a little bit (as noted, it no longer works, as it requires a username and password)

I’ve switched it out with the variables from Ward’s script in this respect:

*curl -s $CURL_OPTS -k -u “apikey:$API_KEY” -X POST *

I’m receiving the emails now, but no transcription, this is the end of the message, there should be transcription text below this:

\r\n\r\n Message contents:

Add -v , maybe --trace-ascii to your curl request. It might ‘surprise’ you or possibly enlighten you, from bash

man curl

Thanks Dicko, I’ll have to give that a try. I know it’s not my api credentials, as I am able to get that to work using a script that was included called bluemix-test and running it does give me a transcribed output.


IBM no longer issues USERNAME AND PASSWORD credentials


curl -k -u “apikey:$API_KEY” -X POST --limit-rate 40000 --header “Content-Type: audio/wav” --data-binary @/var/www/html/admin/modules/directory/sounds/en/cdir-transferring-further-assistance.wav “$URL/v1/recognize?model=en-US_NarrowbandModel” 1>audio.txt

TRANSCRIPT=cat audio.txt | grep transcript | sed 's#^.*"transcript": "##g' | sed 's# "$##g'
rm audio.txt

Wrap your code in a pre-formatted text block, please. Otherwise, the code is smply too hard to read.

... “$URL/v1/recognize?model=en-US_NarrowbandModel” >audio.txt

TRANSCRIPT=`grep transcript audio.txt | sed 's#^.*"transcript": "##g' | sed 's# "$##g'

this gets rid of the extransous ‘cat’ and the ‘1>’ output redirection.

FInally, the “TRANSCRIPT=…” line removes the “transcript:” at the front of the text and the quotation mark at the end. For purposes of testing, you could easily just “cat audio.txt” instead of the code at the end of the code. For that matter, you could just remove everything from the “1>” to the end of the script and use the output of the curl command as the output of the script.

There is a script here that was developed independently from NV:

Thanks Cynjut, I apologize for not formatting correctly, I did not see that option,I see it now.

I’ve had to alter this one a bit, as well, as it also conforms to the user/password model that bluemix had.

# Send WAV to Watson Speech to Text API. Must use "Narrowband" (aka 8k) model since WAV is 8k sample
#       curl -s $CURL_OPTS -k -u $API_USERNAME:$API_PASSWORD -X POST \
    curl -s $CURL_OPTS -k -u “apikey:$API_KEY” -X POST
            --limit-rate 40000 \
            --header "Content-Type: audio/wav" \
            --data-binary @stream.part3.wav \

Still no joy, like before I’m not receiving an email with this script, and running it while running tail -f /var/log/maillog, I again do not have any output.

Your post is either incomplete or you forgot to actually connect to any server

Thank you all for your help and input.

I’ve gotten this to work. Apart from making sure that the prerequisites were installed, there was definitely one tweak required, but in the end it was Ward’s script that did the trick.

As noted in my original post, Ward had created a script that addressed the changes made by IBM, kudos to him for this, without his work I would be completely stuck in the mud that post is here: http://nerdvittles.com/?p=25136):

I think one issue I had was the level that the bluemix credentials requipred; the test script that you can bash that ward provided was also very helpful to mak sure that this was working correctly.

  1. Configure bluemix Credentials: Make sure that the credentials are using AT LEAST writer permissions

  2. Edit /usr/sbin/sendmailibm so that it uses sendmail instead of sendmail.orig

vi /usr/sbin/sendmailibm

# send the mail thru sendmail
#cat stream.new | sendmail.orig -t
cat stream.new | sendmail -t

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.