Google Speech to Text integration with Asterisk live calls
up vote
1
down vote
favorite
i have setup google speech to test with asterisk. i have done following to get speech to text.
when call comes in i record the message,
convert to google supported bit rate audio file using sox
send the audio file to google cloud speech and get the response.
is there anyway we can send live call audio instead of recording to google cloud speed and get response?
please see my following code.
<?php
require_once('/scripts/phpagi/phpagi.php');
$agi = new AGI();
$agi->answer();
$unique_id = "$argv[1]";
$caller_id = "$argv[2]";
$agi->record_file("/scripts/google-speech-to-text/recordings/$unique_id-$caller_id","wav",' ',-1,null,false,5);
echo system("sox /scripts/google-speech-to-text/recordings/$unique_id-$caller_id.wav -b 16 -s -c 1 -r 16k -t raw /scripts/google-speech-to-text/recordings/$unique_id-$caller_id.raw");
putenv('GOOGLE_APPLICATION_CREDENTIALS=/scripts//file.json');
# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';
# Imports the Google Cloud client library
use GoogleCloudSpeechSpeechClient;
# Your Google Cloud Platform project ID
$projectId = 'myprojectid';
# Instantiates a client
$speech = new SpeechClient([
'projectId' => $projectId,
'languageCode' => 'en-US',
]);
# The name of the audio file to transcribe
$fileName = '/scripts/google-speech-to-text/recordings/$unique_id-$caller_id.raw';
# The audio file's encoding and sample rate
$options = [
'encoding' => 'LINEAR16',
'sampleRateHertz' => 16000,
'model' => 'phone_call',
];
# Detects speech in the audio file
$results = $speech->recognize(fopen($fileName, 'r'), $options);
foreach ($results as $result) {
$getresult = $result->alternatives()[0]['transcript'] ;
}
echo $getresult;
?>
php asterisk
New contributor
add a comment |
up vote
1
down vote
favorite
i have setup google speech to test with asterisk. i have done following to get speech to text.
when call comes in i record the message,
convert to google supported bit rate audio file using sox
send the audio file to google cloud speech and get the response.
is there anyway we can send live call audio instead of recording to google cloud speed and get response?
please see my following code.
<?php
require_once('/scripts/phpagi/phpagi.php');
$agi = new AGI();
$agi->answer();
$unique_id = "$argv[1]";
$caller_id = "$argv[2]";
$agi->record_file("/scripts/google-speech-to-text/recordings/$unique_id-$caller_id","wav",' ',-1,null,false,5);
echo system("sox /scripts/google-speech-to-text/recordings/$unique_id-$caller_id.wav -b 16 -s -c 1 -r 16k -t raw /scripts/google-speech-to-text/recordings/$unique_id-$caller_id.raw");
putenv('GOOGLE_APPLICATION_CREDENTIALS=/scripts//file.json');
# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';
# Imports the Google Cloud client library
use GoogleCloudSpeechSpeechClient;
# Your Google Cloud Platform project ID
$projectId = 'myprojectid';
# Instantiates a client
$speech = new SpeechClient([
'projectId' => $projectId,
'languageCode' => 'en-US',
]);
# The name of the audio file to transcribe
$fileName = '/scripts/google-speech-to-text/recordings/$unique_id-$caller_id.raw';
# The audio file's encoding and sample rate
$options = [
'encoding' => 'LINEAR16',
'sampleRateHertz' => 16000,
'model' => 'phone_call',
];
# Detects speech in the audio file
$results = $speech->recognize(fopen($fileName, 'r'), $options);
foreach ($results as $result) {
$getresult = $result->alternatives()[0]['transcript'] ;
}
echo $getresult;
?>
php asterisk
New contributor
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
i have setup google speech to test with asterisk. i have done following to get speech to text.
when call comes in i record the message,
convert to google supported bit rate audio file using sox
send the audio file to google cloud speech and get the response.
is there anyway we can send live call audio instead of recording to google cloud speed and get response?
please see my following code.
<?php
require_once('/scripts/phpagi/phpagi.php');
$agi = new AGI();
$agi->answer();
$unique_id = "$argv[1]";
$caller_id = "$argv[2]";
$agi->record_file("/scripts/google-speech-to-text/recordings/$unique_id-$caller_id","wav",' ',-1,null,false,5);
echo system("sox /scripts/google-speech-to-text/recordings/$unique_id-$caller_id.wav -b 16 -s -c 1 -r 16k -t raw /scripts/google-speech-to-text/recordings/$unique_id-$caller_id.raw");
putenv('GOOGLE_APPLICATION_CREDENTIALS=/scripts//file.json');
# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';
# Imports the Google Cloud client library
use GoogleCloudSpeechSpeechClient;
# Your Google Cloud Platform project ID
$projectId = 'myprojectid';
# Instantiates a client
$speech = new SpeechClient([
'projectId' => $projectId,
'languageCode' => 'en-US',
]);
# The name of the audio file to transcribe
$fileName = '/scripts/google-speech-to-text/recordings/$unique_id-$caller_id.raw';
# The audio file's encoding and sample rate
$options = [
'encoding' => 'LINEAR16',
'sampleRateHertz' => 16000,
'model' => 'phone_call',
];
# Detects speech in the audio file
$results = $speech->recognize(fopen($fileName, 'r'), $options);
foreach ($results as $result) {
$getresult = $result->alternatives()[0]['transcript'] ;
}
echo $getresult;
?>
php asterisk
New contributor
i have setup google speech to test with asterisk. i have done following to get speech to text.
when call comes in i record the message,
convert to google supported bit rate audio file using sox
send the audio file to google cloud speech and get the response.
is there anyway we can send live call audio instead of recording to google cloud speed and get response?
please see my following code.
<?php
require_once('/scripts/phpagi/phpagi.php');
$agi = new AGI();
$agi->answer();
$unique_id = "$argv[1]";
$caller_id = "$argv[2]";
$agi->record_file("/scripts/google-speech-to-text/recordings/$unique_id-$caller_id","wav",' ',-1,null,false,5);
echo system("sox /scripts/google-speech-to-text/recordings/$unique_id-$caller_id.wav -b 16 -s -c 1 -r 16k -t raw /scripts/google-speech-to-text/recordings/$unique_id-$caller_id.raw");
putenv('GOOGLE_APPLICATION_CREDENTIALS=/scripts//file.json');
# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';
# Imports the Google Cloud client library
use GoogleCloudSpeechSpeechClient;
# Your Google Cloud Platform project ID
$projectId = 'myprojectid';
# Instantiates a client
$speech = new SpeechClient([
'projectId' => $projectId,
'languageCode' => 'en-US',
]);
# The name of the audio file to transcribe
$fileName = '/scripts/google-speech-to-text/recordings/$unique_id-$caller_id.raw';
# The audio file's encoding and sample rate
$options = [
'encoding' => 'LINEAR16',
'sampleRateHertz' => 16000,
'model' => 'phone_call',
];
# Detects speech in the audio file
$results = $speech->recognize(fopen($fileName, 'r'), $options);
foreach ($results as $result) {
$getresult = $result->alternatives()[0]['transcript'] ;
}
echo $getresult;
?>
php asterisk
php asterisk
New contributor
New contributor
New contributor
asked Nov 21 at 18:50
IT Curves
61
61
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Yes, you can use EAGI to do continiuos recognition.
Unfortanly it not stable(do core dump etc) enought at current moment
does it live speech recognition or same i have to record the voice and get the result?
– IT Curves
yesterday
No,it is continious via GRPC
– arheops
21 hours ago
I followed cloud.google.com/speech-to-text/docs/streaming-recognize to setup recorded file streaming and its working fine. is there any example of live call streaming in php script?
– IT Curves
8 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Yes, you can use EAGI to do continiuos recognition.
Unfortanly it not stable(do core dump etc) enought at current moment
does it live speech recognition or same i have to record the voice and get the result?
– IT Curves
yesterday
No,it is continious via GRPC
– arheops
21 hours ago
I followed cloud.google.com/speech-to-text/docs/streaming-recognize to setup recorded file streaming and its working fine. is there any example of live call streaming in php script?
– IT Curves
8 hours ago
add a comment |
up vote
0
down vote
Yes, you can use EAGI to do continiuos recognition.
Unfortanly it not stable(do core dump etc) enought at current moment
does it live speech recognition or same i have to record the voice and get the result?
– IT Curves
yesterday
No,it is continious via GRPC
– arheops
21 hours ago
I followed cloud.google.com/speech-to-text/docs/streaming-recognize to setup recorded file streaming and its working fine. is there any example of live call streaming in php script?
– IT Curves
8 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
Yes, you can use EAGI to do continiuos recognition.
Unfortanly it not stable(do core dump etc) enought at current moment
Yes, you can use EAGI to do continiuos recognition.
Unfortanly it not stable(do core dump etc) enought at current moment
answered 2 days ago
arheops
11.8k11122
11.8k11122
does it live speech recognition or same i have to record the voice and get the result?
– IT Curves
yesterday
No,it is continious via GRPC
– arheops
21 hours ago
I followed cloud.google.com/speech-to-text/docs/streaming-recognize to setup recorded file streaming and its working fine. is there any example of live call streaming in php script?
– IT Curves
8 hours ago
add a comment |
does it live speech recognition or same i have to record the voice and get the result?
– IT Curves
yesterday
No,it is continious via GRPC
– arheops
21 hours ago
I followed cloud.google.com/speech-to-text/docs/streaming-recognize to setup recorded file streaming and its working fine. is there any example of live call streaming in php script?
– IT Curves
8 hours ago
does it live speech recognition or same i have to record the voice and get the result?
– IT Curves
yesterday
does it live speech recognition or same i have to record the voice and get the result?
– IT Curves
yesterday
No,it is continious via GRPC
– arheops
21 hours ago
No,it is continious via GRPC
– arheops
21 hours ago
I followed cloud.google.com/speech-to-text/docs/streaming-recognize to setup recorded file streaming and its working fine. is there any example of live call streaming in php script?
– IT Curves
8 hours ago
I followed cloud.google.com/speech-to-text/docs/streaming-recognize to setup recorded file streaming and its working fine. is there any example of live call streaming in php script?
– IT Curves
8 hours ago
add a comment |
IT Curves is a new contributor. Be nice, and check out our Code of Conduct.
IT Curves is a new contributor. Be nice, and check out our Code of Conduct.
IT Curves is a new contributor. Be nice, and check out our Code of Conduct.
IT Curves is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53418761%2fgoogle-speech-to-text-integration-with-asterisk-live-calls%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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