Upload files to "/"
This commit is contained in:
commit
045e8d686c
65
README.md
Normal file
65
README.md
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# Transcription Voice Mail for FreePBX
|
||||||
|
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Attaching a transcript to the email of what was said in the voicemail recording using Google Cloud Speech-to-text API
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# sendmail-gcloud
|
||||||
|
#
|
||||||
|
# Installation instructions
|
||||||
|
# Copy the content of this file to /usr/sbin/sendmail-gcloud
|
||||||
|
#
|
||||||
|
# Google Account
|
||||||
|
# ---------------
|
||||||
|
# Create a Google Cloud account if you don't have one yet. Free trial is available at https://console.cloud.google.com/freetrial
|
||||||
|
# Within console.cloud.google.com search for Cloud Speech-to-Text API and enable it
|
||||||
|
#
|
||||||
|
# From the Linux command line on the FreePBX machine
|
||||||
|
# -------------------------------------------
|
||||||
|
# Follow steps 1 and 2 of the instructions on Google Cloud https://cloud.google.com/sdk/docs/downloads-yum
|
||||||
|
# Run the following commands on FreePBX;
|
||||||
|
# cd /usr/sbin/
|
||||||
|
# chown asterisk:asterisk sendmail-gcloud
|
||||||
|
# chmod 744 sendmail-gcloud
|
||||||
|
# chmod 777 /usr/bin/dos2unix
|
||||||
|
#
|
||||||
|
# Verify that you have the following (by simply running the command) and if not use yum install;
|
||||||
|
# jq
|
||||||
|
# sox
|
||||||
|
# flac
|
||||||
|
# dos2unix -V
|
||||||
|
# Ensure dos2unix is executable by the asterisk user (chmod 777 /usr/bin/dos2unix)
|
||||||
|
#
|
||||||
|
# Connect FreePBX to Google Cloud
|
||||||
|
# su asterisk
|
||||||
|
# gcloud auth login
|
||||||
|
# CLI will provide you a url. Copy that and paste it into your browser. Google will give you a verification code to copy. Paste it into the cli waiting for a verification code.
|
||||||
|
#
|
||||||
|
# Open FreePBX web interface
|
||||||
|
# Go to Settings > Voicemail Admin > Settings > Email Config
|
||||||
|
# Change Mail Command to: /usr/sbin/sendmail-gcloud
|
||||||
|
# Submit and apply changes
|
||||||
|
#
|
||||||
|
# Original source created by N. Bernaerts: https://github.com/NicolasBernaerts/debian-scripts/tree/master/asterisk
|
||||||
|
# modified per: https://jrklein.com/2015/08/17/asterisk-voicemail-transcription-via-ibm-bluemix-speech-to-text-api/
|
||||||
|
# modified per: https://gist.github.com/lgaetz/2cd9c54fb1714e0d509f5f8215b3f5e6
|
||||||
|
# current version: https://gist.github.com/tony722/7c6d86be2e74fa10a1f344a4c2b093ea
|
||||||
|
#
|
||||||
|
# Notes: This is a script modified from the original to work with FreePBX so that email notifications sent from
|
||||||
|
# Asterisk voicemail contain a speech to text transcription provided by Google Cloud Speech API
|
||||||
|
#
|
||||||
|
# License: There are no explicit license terms on the original script or on the blog post with modifications
|
||||||
|
# I'm assumig GNU/GPL2+ unless notified otherwise by copyright holder(s)
|
||||||
|
#
|
||||||
|
# Version History:
|
||||||
|
# 2021-05-06 Add fix by dcat127: trim flac file to 59 seconds
|
||||||
|
# 2020-08-27 Add fix by chrisduncansn
|
||||||
|
# Minor edit in instruction wording
|
||||||
|
# 2020-05-27 Add instructions from sr10952
|
||||||
|
# Add export fix by levishores
|
||||||
|
# 2019-02-27 Initial commit by tony722
|
||||||
35
app.py
Normal file
35
app.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import os
|
||||||
|
from google.cloud import speech
|
||||||
|
from google.cloud.speech import RecognitionConfig, RecognitionAudio
|
||||||
|
|
||||||
|
|
||||||
|
# Set the path to your Google Cloud service account key
|
||||||
|
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "credentials.json"
|
||||||
|
|
||||||
|
# Initialize the Google Cloud Speech client
|
||||||
|
client = speech.SpeechClient()
|
||||||
|
|
||||||
|
# Path to the audio file
|
||||||
|
audio_file_path = "he_speech_demo.wav"
|
||||||
|
|
||||||
|
# Read the audio file
|
||||||
|
with open(audio_file_path, 'rb') as audio_file:
|
||||||
|
content = audio_file.read()
|
||||||
|
|
||||||
|
# Create a RecognitionAudio instance with the audio content
|
||||||
|
audio = RecognitionAudio(content=content)
|
||||||
|
|
||||||
|
# Create a RecognitionConfig instance with the appropriate settings
|
||||||
|
config = RecognitionConfig(
|
||||||
|
#encoding=RecognitionConfig.AudioEncoding.LINEAR16,
|
||||||
|
sample_rate_hertz=8000,
|
||||||
|
model='telephony',
|
||||||
|
language_code='iw-IL'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Transcribe the audio file
|
||||||
|
response = client.recognize(config=config, audio=audio)
|
||||||
|
|
||||||
|
# Print the transcription
|
||||||
|
for result in response.results:
|
||||||
|
print('Transcript: {}'.format(result.alternatives[0].transcript))
|
||||||
BIN
en_speech_demo.wav
Normal file
BIN
en_speech_demo.wav
Normal file
Binary file not shown.
BIN
he_speech_demo.wav
Normal file
BIN
he_speech_demo.wav
Normal file
Binary file not shown.
BIN
he_speech_demo_2.wav
Normal file
BIN
he_speech_demo_2.wav
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user