Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "Improved debbuging output."

This reverts commit 7b3e840.
  • Loading branch information...
commit 135d7d2ddbb43d6a78b1725937cdcb2c3746f160 1 parent 7b3e840
@zaf authored
Showing with 20 additions and 31 deletions.
  1. +13 −19 speech-recog.agi
  2. +7 −12 wolfram/wolfram.agi
View
32 speech-recog.agi
@@ -100,7 +100,7 @@ $name = " -- $AGI{request}:";
die "$name flac is missing. Aborting.\n" if (!$flac);
chomp($flac);
-&debug_msg("$name Found flac in: $flac", $debug);
+print STDERR "$name Found flac in: $flac\n" if ($debug);
# Setting recording file format according to sample rate. #
if ($samplerate == 16000) {
@@ -127,11 +127,11 @@ if (length($AGI{arg_4})) {
}
# Answer channel if not already answered #
-&debug_msg("$name Checking channel status.", $debug);
+print STDERR "$name Checking channel status.\n" if ($debug);
print "CHANNEL STATUS\n";
@result = &checkresponse();
if ($result[0] == 4) {
- &debug_msg("$name Answering channel.", $debug);
+ print STDERR "$name Answering channel.\n" if ($debug);
print "ANSWER\n";
&checkresponse();
}
@@ -143,7 +143,7 @@ if ($result[0] == 4) {
id => -1,
confidence => -1,
);
-&debug_msg("$name Clearing channel variables.", $debug);
+print STDERR "$name Clearing channel variables.\n" if ($debug);
foreach (keys %response) {
print "SET VARIABLE \"$_\" \"$response{$_}\"\n";
&checkresponse();
@@ -156,19 +156,19 @@ $SIG{'HUP'} = \&int_handler;
# Record file #
($fh, $tmpname) = tempfile("stt_XXXXXX", DIR => $tmpdir, UNLINK => 1);
-&debug_msg("$name Recording Format: $format, Rate: $samplerate Hz,
- Timeout: $timeout ms, Interrupt keys: $intkey", $debug);
+print STDERR "$name Recording Format: $format, Rate: $samplerate Hz,
+ Timeout: $timeout ms, Interrupt keys: $intkey\n" if ($debug);
print "RECORD FILE $tmpname $format \"$intkey\" \"$timeout\" $beep\n";
@result = &checkresponse();
die "$name Failed to record file, aborting...\n" if ($result[0] == -1);
if ($debug) {
- &debug_msg("$name Languge: $language, SSL: $use_ssl", $debug);
- &debug_msg("$name Playing back recorded file.", $debug);
+ print STDERR "$name Languge: $language, SSL: $use_ssl\n";
+ print STDERR "$name Playing back recorded file.\n";
print "STREAM FILE $tmpname \"\"\n";
@result = &checkresponse();
- &debug_msg("$name Failed to play file", $debug) if ($result[0] == -1);
+ print STDERR "$name Failed to play file\n" if ($result[0] == -1);
}
# Encode file to flac. #
@@ -201,7 +201,7 @@ die "$name Unable to get speech data.\n" if (!$uaresponse->is_success);
if ($uaresponse->content =~ /^\{"status":(\d*),"id":"(.*)","hypotheses":\[(.*)\]\}$/) {
$response{status} = "$1";
$response{id} = "$2";
- &debug_msg("Error reading audio file", 1) if ($response{status} == 5);
+ print STDERR "Error reading audio file\n" if ($response{status} == 5);
if ($3 =~ /^\{"utterance":"(.*)","confidence":(.*)\}/) {
$response{utterance} = "$1";
$response{confidence} = "$2";
@@ -210,21 +210,15 @@ if ($uaresponse->content =~ /^\{"status":(\d*),"id":"(.*)","hypotheses":\[(.*)\]
}
}
-&debug_msg("$name The response was: $uaresponse->content", $debug);
+print STDERR "$name The response was:\n", $uaresponse->content if ($debug);
foreach (keys %response) {
- &debug_msg("$name Setting variable: $_ = $response{$_}", $debug);
+ print STDERR "$name Setting variable: $_ = $response{$_}\n" if ($debug);
print "SET VARIABLE \"$_\" \"$response{$_}\"\n";
&checkresponse();
}
exit;
-sub debug_msg {
- my ($db_msg, $db_level) = @_;
- print "VERBOSE \"$db_msg\" $db_level\n" if ($db_level);
- &checkresponse();
-}
-
sub checkresponse {
my $input = <STDIN>;
my @values;
@@ -252,7 +246,7 @@ sub int_handler {
END {
if ($tmpname) {
- &debug_msg("$name Cleaning temp files.", $debug);
+ print STDERR "$name Cleaning temp files.\n" if ($debug);
unlink glob "$tmpname*";
}
}
View
19 wolfram/wolfram.agi
@@ -68,10 +68,10 @@ if (!$app_id) {
}
if (!length($AGI{arg_1})) {
- &return_var("No question passed to Wolfram.");
+ &return_var("No text passed to Wolfram.");
die "$name No text passed, Aborting.\n";
}
-&debug_msg("$name Questions is: $AGI{arg_1}", $debug);
+print STDERR "$name Questions is: $AGI{arg_1}\n" if($debug);
$question = escape($AGI{arg_1});
if ($use_ssl) {
@@ -82,6 +82,7 @@ if ($use_ssl) {
$ua = LWP::UserAgent->new;
}
+$ua = LWP::UserAgent->new;
$ua->agent("Mozilla/5.0 (X11; Linux) AppleWebKit/535.2 (KHTML, like Gecko)");
$ua->timeout(15);
my $ua_request = HTTP::Request->new(
@@ -96,7 +97,7 @@ if (!$ua_response->is_success) {
$w_reply = XMLin($ua_response->content);
if ($w_reply->{success} eq 'false') {
- &debug_msg("$name Wolfram returned no answer.", $debug);
+ print STDERR "$name Wolfram returned no answer.\n" if ($debug);
&return_var("I don't know how to answer that.");
exit;
}
@@ -142,10 +143,10 @@ if (!$results) {
# In case we were not able to locate any answers. #
if (!$results) {
- &debug_msg("$name Failed to get any answer.", $debug);
+ print STDERR "$name Failed to get any answer.\n" if ($debug);
&return_var("Failed to get any answer.");
} else {
- &debug_msg("$name Answer is:$answer", $debug);
+ print STDERR "$name Answer is:$answer\n" if ($debug);
&return_var($answer);
}
exit;
@@ -167,17 +168,11 @@ sub add_answer {
# Store answers in channel variable. #
sub return_var {
my $text = shift;
- &debug_msg("$name Setting: $var_name to: $text", $debug);
+ print STDERR "$name Setting $var_name to $text\n" if ($debug);
print "SET VARIABLE \"$var_name\" \"$text\"\n";
&checkresponse();
}
-sub debug_msg {
- my ($db_msg, $db_level) = @_;
- print "VERBOSE \"$db_msg\" $db_level\n" if ($db_level);
- &checkresponse();
-}
-
sub checkresponse {
my $input = <STDIN>;
my @values;
Please sign in to comment.
Something went wrong with that request. Please try again.