Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Small fix in audio format detection.

  • Loading branch information...
commit 986d282a376c2a41554082eb94074181ada40467 1 parent c7c0b0b
@zaf authored
Showing with 22 additions and 21 deletions.
  1. +22 −21 speech-recog.agi
View
43 speech-recog.agi
@@ -185,14 +185,13 @@ if ($result[0] == 4) {
}
# Setting recording file format according to sample rate. #
-if ($samplerate == 0) {
- ($format, $samplerate) = detect_format();
-} elsif ($samplerate == 16000) {
- $format = "sln16";
-} else {
- $format = "sln";
- $samplerate = 8000;
-}
+if ($samplerate == 0) { ($format, $samplerate) = detect_format(); }
+elsif ($samplerate == 12000) { $format = "sln12"; }
+elsif ($samplerate == 16000) { $format = "sln16"; }
+elsif ($samplerate == 32000) { $format = "sln32"; }
+elsif ($samplerate == 44100) { $format = "sln44"; }
+elsif ($samplerate == 48000) { $format = "sln48"; }
+else { ($format, $samplerate) = ("sln", 8000); }
# Initialise User angent #
if ($use_ssl) {
@@ -286,34 +285,36 @@ sub checkresponse {
$input =~ /result=(-?\d+)\s?(.*)$/;
if (!length($1)) {
warn "$name Command failed: $input\n";
- @values = ("-1");
+ @values = (-1, -1);
} else {
warn "$name Command returned: $input\n" if ($debug);
@values = ("$1", "$2");
}
} else {
warn "$name Unexpected result: $input\n";
- @values = ("-1");
+ @values = (-1, -1);
}
return @values;
}
sub detect_format {
+ my @format;
print "GET FULL VARIABLE \${CHANNEL(audionativeformat)}\n";
my @reply = checkresponse();
- if ($reply[0] == 1 && $reply[1] =~ /silk12|sln12/) {
- return ("sln12", 12000);
- } elsif ($reply[0] == 1 && $reply[1] =~ /g722|speex16|slin16|silk16|siren7/) {
- return ("sln16", 16000);
- } elsif ($reply[0] == 1 && $reply[1] =~ /speex32|slin32|celt32|siren14/) {
- return ("sln32", 32000);
- } elsif ($reply[0] == 1 && $reply[1] =~ /celt44|slin44/) {
- return ("sln44", 44100);
- } elsif ($reply[0] == 1 && $reply[1] =~ /celt48|slin48/) {
- return ("sln48", 48000);
+ if ($reply[1] =~ /silk12|sln12/) {
+ @format = ("sln12", 12000);
+ } elsif ($reply[1] =~ /g722|speex16|slin16|silk16|siren7/) {
+ @format = ("sln16", 16000);
+ } elsif ($reply[1] =~ /speex32|slin32|celt32|siren14/) {
+ @format = ("sln32", 32000);
+ } elsif ($reply[1] =~ /celt44|slin44/) {
+ @format = ("sln44", 44100);
+ } elsif ($reply[1] =~ /celt48|slin48/) {
+ @format = ("sln48", 48000);
} else {
- return ("sln", 8000);
+ @format = ("sln", 8000);
}
+ return @format;
}
sub int_handler {
Please sign in to comment.
Something went wrong with that request. Please try again.