The #OpenSourceLounge

Next open source lounge is a week from tonight: Sangoma Meet

3 Likes

:arrow_up: :arrow_up: :arrow_up: Reminder of tonights Open Source Lounge at 7pm Eastern :arrow_up: :arrow_up: :arrow_up:

1 Like

Good session tonight. @slobera did a pretty detailed walkthru on how to use Dynamic Routes for phone surveys and for reporting on IVR selections and @dicko talked about using vosk for speech to text.

Thanks guys.

5 Likes

To reduce it to the basics , vosk is a very lightweight offline STT parser that uses the kaldi speech engine and can easily run in a docker container on a Pi4 or bigger. So after doing the

thing, you can construct a dialplan stub much like

exten = 999,1,Answer
same = n,Wait(1)
; a red herring here same = n,Monitor(wav,dick-${STRFTIME(${EPOCH},,%Y%m%d_%H%M%S)})
same = n,SpeechCreate
same = n,SpeechBackground(pls-entr-num-uwish2-call)
same = n,StopMonitor
same = n,noop(${SPEECH_TEXT(0)})
same = n,Set(result=${SHELL(/var/lib/asterisk/bin/thingy.py "${SPEECH_TEXT(0)}")})
same = n,Playback(you-entered)
same = n,SayDigits(${result})

same = n,noop(${result})
.
.
.

where thingy.py is much like

#!/usr/bin/python3
import sys
import phonenumbers
# dicktionary (sic) of acceptable words
num_dict = {
# button name pronounced or mis-pronounced
    'oh' : '0',
    'no' : '0',
    'o' : '0',
    'zero' : '0',
    'reject' : '0',
    'one': '1',
    'accept' : '1',
    'yes' : '1',
    'won': '1',
    'two': '2',
    'to': '2',
    'too': '2',
    'three': '3',
    'four': '4',
    'for': '4',
    'fool': '4',
    'five': '5',
    'six': '6',
    'seven': '7',
    'eight': '8',
    'nine': '9',
    'plus' : '+',
    'pound' : '#',
    'hash' : '#',
    'star' : '*',
    'asterisk' : '*',
    'hundred' : '00',
# nusance words to be ignored here
    'call' : '',
    'please' : '',
    'dial' : '',
# IVR or other endpoints described here
    'sales' : '602',
    'accounts' : '*666',
    'accounting' : '*666',
    'operator' : '0',
# speed dials can be constructed here
    'dick'   : '13235551212',
    'tom'   : '12125551212',

phone_number = sys.argv[1]
outnum = ""
for word in phone_number.split():
    try:
        outnum  += (num_dict[word])
    except:
        pass
if outnum == "":
    print ("nothing heard\n", file=sys.stderr)
    print ("noaudio")
    sys.exit(1)
if outnum == "911":
    print ("emergency routines need to be put here !!!!!!!")
print ("I heard",outnum,file=sys.stderr)
if len(outnum)> 9:
    parsednum = phonenumbers.parse(outnum, "US")
    valid= phonenumbers.is_valid_number(parsednum)
    if valid:
        willdial = phonenumbers.format_number(parsednum, phonenumbers.PhoneNumberFormat.E164)
        dialnum = phonenumbers.parse(willdial, None)
        print ("Validated as", dialnum, "\n", file=sys.stderr)
        print (willdial, end='')
        if not valid:
            woulddial = phonenumbers.format_number(parsednum, phonenumbers.PhoneNumberFormat.E164)
            print ("Would try and dial  ", woulddial, "but that is an invalid number\n" , file=sys.stderr)
            print (outnum,"\b,invalid", end='')
            sys.exit(2)
    print ("Will dial",outnum, "\n", file=sys.stderr)
    print (outnum, end = '')

The python script is also intended to be useful as a speech to text dialer plus number verifier and ‘normalizer’ that will recognize most every e164 ‘text’ strings

“plus three three . . .” will check France
“oh oh three three . . .” also.
Whereas “one one three three for oh oh won one one too” will be rejected as an invalid NANP number.
But “two oh one for four four one two three four” is seen as legit.

All valid numbers longer than nine digits after parsing recognized words are returned in e164 nomenclature if valid.

Those less are returned ‘as said’ within the limitations of the ‘dicktionary’ which enables access to all dialplans internal to FreePBX, thereby bypassing any DTMF detection, (great for anti-spam IMHO )

Food for thought here?

edit:

Perhaps a moderator could appropriately split this off to a new thread, it really should not be here in this #OpenSourceLounge thread, (Mea Culpa :slight_smile: )

6 Likes

Just FYI, by Asterisk 21 (so two years) things like Monitor, Macro, MeetMe and Chan_SIP are marked for removal. I would highly suggest looking at updating any custom scripts or dialplan dependant on them with their proper replacements.

1 Like

There is currently no “proper” replacement for monitor in this app, which is why I use it here.

I only want the ‘in’ leg, the out leg that mixmonitor always mixes down to mono would pollute my later ‘vectorizing’ of the speaker.

Next Open Source Lounge is Thursday evening. Drop by and say hi …

1 Like

Reminder of tonight’s OSS Lounge. We’ll be talking about FreePBX 16 with a review of features that are already published as well as a sneak peak of some work yet to be published.

Happy hour starts at 7pm Eastern.

What’s tonight’s meet number?

The URL has been standardized as https://meet.sangoma.com/open-source-lounge

If you are asking about the call in number? No idea.

:desktop_computer: Join this meeting from your computer or mobile device:

:telephone_receiver: Want to join using a phone?
Dial-in: +1.202.600.3995 | PIN: 655932234#
[ tel:+12026003995,655932234#, ]

:globe_with_meridians: Looking for a different dial-in number in your area?

Reminder that the next OpenSourceLounge is next Thursday, Aug 12 at 7pm Eastern Sangoma Meet

:arrow_up::arrow_up: Reminder of tonight’s Open Source Lounge. See you at 7pm Eastern :arrow_up::arrow_up:

That was a good one, thanks to you all.

4 Likes

Excellent discussion – really enjoyed all of the subjects – and Lorne, I’m thinking about how to add that feature to the allow list!

4 Likes

@lgaetz Are there"minutes" or a recording?

Neither minutes nor a recording. It’s a casual gathering, sometimes with a topic or presentation, sometimes not.

Great meeting – thanks to everyone for joining us!

Missed it this time :frowning:

Reminder that the next OSS Lounge is this coming Thursday Sept 9th at 7pm Eastern. Sangoma Meet