ports/145370: Additional port for Freeswitch port changes.
Eric F Crist
ecrist at secure-computing.net
Sun Apr 4 02:30:07 UTC 2010
>Number: 145370
>Category: ports
>Synopsis: Additional port for Freeswitch port changes.
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Apr 04 02:30:07 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Eric F Crist
>Release: FreeBSD 8.0-RELEASE amd64
>Organization:
Secure Computing Networks
FusionPBX
>Environment:
System: FreeBSD cartman.secure-computing.net 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:02:08 UTC 2009 root at mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
>Description:
Additional port for new freeswitch structure.
>How-To-Repeat:
>Fix:
Apply shar to ports tree.
--- fspizza.shar begins here ---
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# freeswitch-pizzademo/
# freeswitch-pizzademo/files
# freeswitch-pizzademo/files/javascript
# freeswitch-pizzademo/files/javascript/js_modules
# freeswitch-pizzademo/files/javascript/js_modules/SpeechTools.jm
# freeswitch-pizzademo/files/javascript/ps_pizza.js
# freeswitch-pizzademo/distinfo
# freeswitch-pizzademo/pkg-descr
# freeswitch-pizzademo/pkg-plist
# freeswitch-pizzademo/Makefile
#
echo c - freeswitch-pizzademo/
mkdir -p freeswitch-pizzademo/ > /dev/null 2>&1
echo c - freeswitch-pizzademo/files
mkdir -p freeswitch-pizzademo/files > /dev/null 2>&1
echo c - freeswitch-pizzademo/files/javascript
mkdir -p freeswitch-pizzademo/files/javascript > /dev/null 2>&1
echo c - freeswitch-pizzademo/files/javascript/js_modules
mkdir -p freeswitch-pizzademo/files/javascript/js_modules > /dev/null 2>&1
echo x - freeswitch-pizzademo/files/javascript/js_modules/SpeechTools.jm
sed 's/^X//' >freeswitch-pizzademo/files/javascript/js_modules/SpeechTools.jm << 'bb67ff2bd323c8319e07da00f1a837ed'
X/*
X * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
X * Copyright (C) 2005/2006, Anthony Minessale II <anthmct at yahoo.com>
X *
X * Version: MPL 1.1
X *
X * The contents of this file are subject to the Mozilla Public License Version
X * 1.1 (the "License"); you may not use this file except in compliance with
X * the License. You may obtain a copy of the License at
X * http://www.mozilla.org/MPL/
X *
X * Software distributed under the License is distributed on an "AS IS" basis,
X * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
X * for the specific language governing rights and limitations under the
X * License.
X *
X * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
X *
X * The Initial Developer of the Original Code is
X * Anthony Minessale II <anthmct at yahoo.com>
X * Portions created by the Initial Developer are Copyright (C)
X * the Initial Developer. All Rights Reserved.
X *
X * Contributor(s):
X *
X * Anthony Minessale II <anthmct at yahoo.com>
X *
X *
X * SpeechTools.jm Speech Detection Interface
X *
X */
X
X/* Constructor for Grammar Class (Class to identify a grammar entity) */
Xfunction Grammar(grammar_name, path, obj_path, min_score, confirm_score, halt) {
X this.grammar_name = grammar_name;
X this.path = path;
X this.min_score = min_score;
X this.confirm_score = confirm_score;
X this.halt = halt;
X this.obj_path = obj_path;
X
X if (!this.min_score) {
X this.min_score = 1;
X }
X
X if (!this.confirm_score) {
X this.confirm_score = 400;
X }
X}
X
X/* Constructor for SpeechDetect Class (Class to Detect Speech) */
Xfunction SpeechDetect(session, mod, ip) {
X this.ip = ip;
X this.session = session;
X this.mod = mod;
X this.grammar_name = undefined;
X this.grammar_hash = new Array();
X this.grammar_name = false;
X this.audio_base = "";
X this.audio_ext = ".wav";
X this.tts_eng = false;
X this.tts_voice = false;
X this.AutoUnload = false;
X this.debug = false;
X
X /* Set the TTS info */
X this.setTTS = function (tts_eng, tts_voice) {
X this.tts_eng = tts_eng;
X this.tts_voice = tts_voice;
X }
X
X /* Set the audio base */
X this.setAudioBase = function (audio_base) {
X this.audio_base = audio_base;
X }
X
X /* Set the audio extension */
X this.setAudioExt= function (audio_ext) {
X this.audio_ext = audio_ext;
X }
X
X /* Add a grammar to be used */
X this.addGrammar = function(grammar_object) {
X this.grammar_hash[grammar_object.grammar_name] = grammar_object;
X }
X
X /* Play an audio file */
X this.streamFile = function(str) {
X var rv;
X if (!str) {
X console_log("error", "No file specified!\n");
X return;
X }
X files = str.split(",");
X for( x = 0; x < files.length; x++) {
X if (!files[x] || files[x] == "noop") {
X continue;
X }
X this.session.streamFile(this.audio_base + files[x] + this.audio_ext);
X }
X }
X
X /* Speak with TTS */
X this.speak = function(str) {
X return this.session.speak(this.tts_eng, this.tts_voice, str);
X }
X
X /* Set the current grammar */
X this.setGrammar = function (grammar_name) {
X var grammar_object = this.grammar_hash[grammar_name];
X
X if (!grammar_object) {
X console_log("error", "Missing Grammar!\n");
X return false;
X }
X
X if (this.grammar_name) {
X if (this.AutoUnload) {
X console_log("debug", "Unloading grammar " + this.grammar_name + "\n");
X this.session.execute("detect_speech", "nogrammar " + this.grammar_name);
X }
X if (grammar_object.path) {
X this.session.execute("detect_speech", "grammar " + grammar_name + " " + grammar_object.path);
X } else {
X this.session.execute("detect_speech", "grammar " + grammar_name);
X }
X } else {
X this.session.execute("detect_speech", this.mod + " " + grammar_name + " " + grammar_object.path + " " + this.ip);
X }
X
X this.grammar_name = grammar_name;
X }
X
X /* Pause speech detection */
X this.pause = function() {
X this.session.execute("detect_speech", "pause");
X }
X
X /* Resume speech detection */
X this.resume = function() {
X this.session.execute("detect_speech", "resume");
X }
X
X /* Stop speech detection */
X this.stop = function() {
X this.session.execute("detect_speech", "stop");
X }
X
X /* Callback function for streaming,TTS or bridged calls */
X this.onInput = function(s, type, inputEvent, _this) {
X try {
X if (type == "event") {
X var speech_type = inputEvent.getHeader("Speech-Type");
X var rv = new Array();
X
X if (!_this.grammar_name) {
X console_log("error", "No Grammar name!\n");
X _this.session.hangup();
X return false;
X }
X
X var grammar_object = _this.grammar_hash[_this.grammar_name];
X
X if (!grammar_object) {
X console_log("error", "Can't find grammar for " + _this.grammar_name + "\n");
X _this.session.hangup();
X return false;
X }
X
X if (speech_type == "begin-speaking") {
X if (grammar_object.halt) {
X return false;
X }
X } else {
X var body = inputEvent.getBody();
X var result;
X var xml;
X
X body = body.replace(/<\?.*?\?>/g, '');
X xml = new XML("<xml>" + body + "</xml>");
X result = xml.result;
X
X _this.lastDetect = body;
X
X if (_this.debug) {
X console_log("debug", "----XML:\n" + body + "\n");
X console_log("debug", "----Heard [" + result.interpretation.input + "]\n");
X console_log("debug", "----Hit score " + result.interpretation. at confidence + "/" +
X grammar_object.min_score + "/" + grammar_object.confirm_score + "\n");
X }
X
X if (result.interpretation. at confidence >= grammar_object.min_score) {
X if (result.interpretation. at confidence < grammar_object.confirm_score) {
X rv.push("_confirm_");
X }
X
X eval("xo = " + grammar_object.obj_path + ";");
X for (x = 0; x < xo.length(); x++) {
X rv.push(xo[x]);
X console_log("info", "----" +xo[x] + "\n");
X }
X } else {
X rv.push("_no_idea_");
X }
X
X }
X delete interp;
X return rv;
X }
X }
X
X catch(err) {
X console_log("crit", "----ERROR:\n" + err + "\n");
X }
X }
X}
X
X/* Constructor for SpeechObtainer Class (Class to collect data from a SpeechDetect Class) */
Xfunction SpeechObtainer(asr, req, wait_time) {
X
X this.items = new Array();
X this.collected_items = new Array();
X this.index = 0;
X this.collected_index = 0;
X this.req = req;
X this.tts_eng = undefined;
X this.tts_voice = false;
X this.asr = asr;
X this.top_sound = false;
X this.add_sound = false;
X this.dup_sound = false;
X this.bad_sound = false;
X this.needConfirm = false;
X this.grammar_name = false;
X this.audio_base = asr.audio_base;
X this.audio_ext = asr.audio_ext;
X this.tts_eng = asr.tts_eng;
X this.tts_voice = asr.tts_voice;
X this.debug = asr.debug;
X
X if (!req) {
X req = 1;
X }
X
X if (!wait_time) {
X wait_time = 5000;
X }
X
X this.waitTime = wait_time + 0;
X
X /* Set the TTS info */
X this.setTTS = function (tts_eng, tts_voice) {
X this.tts_eng = tts_eng;
X this.tts_voice = tts_voice;
X }
X
X /* Set the audio base */
X this.setAudioBase = function (audio_base) {
X this.audio_base = audio_base;
X }
X
X /* Set the audio extension */
X this.setAudioExt= function (audio_ext) {
X this.audio_ext = audio_ext;
X }
X
X /* Set the grammar to use */
X this.setGrammar = function (grammar_name, path, obj_path, min_score, confirm_score, halt) {
X var grammar_object = new Grammar(grammar_name, path, obj_path, min_score, confirm_score, halt);
X this.asr.addGrammar(grammar_object);
X this.grammar_name = grammar_name;
X }
X
X /* Set the top audio file or tts for the collection */
X this.setTopSound = function (top_sound) {
X this.top_sound = top_sound;
X }
X
X /* Set the audio file or tts for misunderstood input */
X this.setBadSound = function (bad_sound) {
X this.bad_sound = bad_sound;
X }
X
X /* Set the audio file or tts for duplicate input */
X this.setDupSound = function (dup_sound) {
X this.dup_sound = dup_sound;
X }
X
X /* Set the audio file or tts for accepted input */
X this.setAddSound = function (add_sound) {
X this.add_sound = add_sound;
X }
X
X /* Add acceptable items (comma sep list) */
X this.addItem = function(item) {
X ia = item.split(",");
X var x;
X for (x = 0; x < ia.length; x++) {
X this.items[this.index++] = ia[x];
X }
X }
X
X this.addItemAlias = function(item,alias) {
X ia = item.split(",");
X var x;
X for (x = 0; x < ia.length; x++) {
X this.items[this.index++] = ia[x] + ":::" + alias;
X }
X }
X
X /* Add a regex */
X this.addRegEx = function(item) {
X this.items[this.index++] = item;
X }
X
X /* Reset the object and delete all collect items */
X this.reset = function() {
X this.collected_index = 0;
X delete this.collected_items;
X this.collected_items = new Array();
X }
X
X /* Stream a file, collecting input */
X this.streamFile = function(str) {
X var rv;
X if (!str) {
X console_log("error", "No file specified!\n");
X return;
X }
X files = str.split(",");
X for( x = 0; x < files.length; x++) {
X if (!files[x] || files[x] == "noop") {
X continue;
X }
X rv = this.asr.session.streamFile(this.audio_base + files[x] + this.audio_ext , this.asr.onInput, this.asr);
X if (rv) {
X break;
X }
X }
X
X return rv;
X }
X
X /* Speak some text, collecting input */
X this.speak = function(str) {
X return this.asr.session.speak(this.tts_eng, this.tts_voice, str, this.asr.onInput, this.asr);
X }
X
X /* Process collected input */
X this.react = function(say_str, play_str) {
X var rv;
X
X
X if (!rv) {
X rv = this.asr.session.collectInput(this.asr.onInput, this.asr, 500);
X }
X if (!rv) {
X this.asr.resume();
X if (this.tts_eng && this.tts_voice) {
X rv = this.speak(say_str);
X } else {
X rv = this.streamFile(play_str);
X }
X }
X
X if (!rv) {
X rv = this.asr.session.collectInput(this.asr.onInput, this.asr, 500);
X }
X
X if (rv && !rv[0]) {
X rv = false;
X }
X
X return rv;
X }
X
X /* Collect input */
X this.run = function() {
X var rv;
X var hit;
X var dup;
X
X if (this.collected_index) {
X this.reset();
X }
X
X if (!this.grammar_name) {
X console_log("error", "No Grammar name!\n");
X this.session.hangup();
X return false;
X }
X
X this.asr.setGrammar(this.grammar_name);
X
X while(this.asr.session.ready() && this.collected_index < this.req) {
X var x;
X this.needConfirm = false;
X if (!rv) {
X rv = this.react(this.top_sound, this.top_sound);
X }
X if (!rv) {
X this.asr.resume();
X rv = this.asr.session.collectInput(this.asr.onInput, this.asr, this.waitTime);
X }
X hit = false;
X if (rv) {
X var items = rv;
X rv = undefined;
X for (y = 0; y < items.length; y++) {
X if (items[y] == "_no_idea_") {
X if (this.debug) {
X console_log("debug", "----We don't understand this\n");
X }
X break;
X }
X if (items[y] == "_confirm_") {
X this.needConfirm = true;
X if (this.debug) {
X console_log("debug", "----We need to confirm this one\n");
X }
X continue;
X }
X
X for(x = 0 ; x < this.index; x++) {
X if (this.debug) {
X console_log("debug", "----Testing [" + y + "] [" + x + "] " + items[y] + " =~ [" + this.items[x] + "]\n");
X }
X str = this.items[x];
X
X ab = str.split(":::");
X
X var re = new RegExp(ab[0], "i");
X match = re.exec(items[y]);
X
X if (match) {
X
X for (i = 0; i < match.length; i++) {
X if (ab.length == 1) {
X rep = match[i];
X } else {
X rep = ab[1];
X }
X
X dup = false;
X for(z = 0; z < this.collected_items.length; z++) {
X if (this.collected_items[z] == rep) {
X dup = true;
X break;
X }
X }
X if (dup) {
X if (this.dup_sound) {
X rv = this.react(this.dup_sound + " " + rep, this.dup_sound + "," + rep);
X }
X } else {
X if (this.debug) {
X console_log("debug", "----Adding " + rep + "\n");
X }
X this.collected_items[this.collected_index++] = rep;
X hit = true;
X if (this.add_sound) {
X rv = this.react(this.add_sound + " " + rep, this.add_sound + "," + rep);
X }
X }
X }
X }
X }
X }
X }
X
X if (!rv) {
X rv = this.asr.session.collectInput(this.asr.onInput, this.asr, 1000);
X }
X
X if (!rv && !hit && !dup) {
X rv = this.react(this.bad_sound, this.bad_sound);
X }
X }
X
X return this.collected_items;
X
X }
X}
bb67ff2bd323c8319e07da00f1a837ed
echo x - freeswitch-pizzademo/files/javascript/ps_pizza.js
sed 's/^X//' >freeswitch-pizzademo/files/javascript/ps_pizza.js << '4bb18679aa511755730e631282a8bb61'
X/*
X * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
X * Copyright (C) 2005/2006, Anthony Minessale II <anthmct at yahoo.com>
X *
X * Version: MPL 1.1
X *
X * The contents of this file are subject to the Mozilla Public License Version
X * 1.1 (the "License"); you may not use this file except in compliance with
X * the License. You may obtain a copy of the License at
X * http://www.mozilla.org/MPL/
X *
X * Software distributed under the License is distributed on an "AS IS" basis,
X * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
X * for the specific language governing rights and limitations under the
X * License.
X *
X * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
X *
X * The Initial Developer of the Original Code is
X * Anthony Minessale II <anthmct at yahoo.com>
X * Portions created by the Initial Developer are Copyright (C)
X * the Initial Developer. All Rights Reserved.
X *
X * Contributor(s):
X *
X * Anthony Minessale II <anthmct at yahoo.com>
X *
X *
X * pizza.js ASR Demonstration Application
X *
X */
Xinclude("javascript/js_modules/SpeechTools.jm");
X
Xfunction on_dtmf(a, b, c) {}
X
Xvar dft_min = 40;
Xvar dft_confirm = 70;
X
X/***************** Initialize The Speech Detector *****************/
Xvar asr = new SpeechDetect(session, "pocketsphinx");
X
X/***************** Be more verbose *****************/
Xasr.debug = 1;
X
X/***************** Set audio params *****************/
Xasr.setAudioBase("/usr/local/share/freeswitch/sounds/pizza/");
Xasr.setAudioExt(".wav");
X
X/***************** Unload the last grammar whenever we activate a new one *****************/
Xasr.AutoUnload = true;
X
X/***************** Create And Configure The Pizza *****************/
Xvar pizza = new Object();
X
X/***************** Delivery Or Take-Out? *****************/
Xpizza.orderObtainer = new SpeechObtainer(asr, 1, 5000);
Xpizza.orderObtainer.setGrammar("pizza_order", "", "result.interpretation.input", dft_min, dft_confirm, true);
Xpizza.orderObtainer.setTopSound("GP-DeliveryorTakeout");
Xpizza.orderObtainer.setBadSound("GP-NoDeliveryorTake-out");
Xpizza.orderObtainer.addItemAlias("Delivery", "Delivery");
Xpizza.orderObtainer.addItemAlias("Takeout,Pickup", "Pickup");
X
X/***************** What Size? *****************/
Xpizza.sizeObtainer = new SpeechObtainer(asr, 1, 5000);
Xpizza.sizeObtainer.setGrammar("pizza_size", "", "result.interpretation.input", dft_min, dft_confirm, true);
Xpizza.sizeObtainer.setTopSound("GP-Size");
Xpizza.sizeObtainer.setBadSound("GP-NI");
Xpizza.sizeObtainer.addItemAlias("^Extra\\s*Large", "ExtraLarge");
Xpizza.sizeObtainer.addItemAlias("^Large$", "Large");
Xpizza.sizeObtainer.addItemAlias("^Medium$", "Medium");
Xpizza.sizeObtainer.addItemAlias("^Small$", "Small");
Xpizza.sizeObtainer.addItemAlias("^Humongous$,^Huge$,^Totally\\s*Humongous$,^Totally", "TotallyHumongous");
X
X/***************** What Type Of Crust? *****************/
Xpizza.crustObtainer = new SpeechObtainer(asr, 1, 5000);
Xpizza.crustObtainer.setGrammar("pizza_crust", "", "result.interpretation.input", dft_min, dft_confirm, true);
Xpizza.crustObtainer.setTopSound("GP-Crust");
Xpizza.crustObtainer.setBadSound("GP-NI");
Xpizza.crustObtainer.addItemAlias("^Hand\\s*Tossed$,^Tossed$", "HandTossed");
Xpizza.crustObtainer.addItemAlias("^Chicago\\s*style$,^Chicago$", "Pan");
Xpizza.crustObtainer.addItemAlias("^Deep,^Pan,^Baked", "Pan");
Xpizza.crustObtainer.addItemAlias("^New\\s*York,^Thin", "Thin");
X
X/***************** Specialty Or Custom? *****************/
Xpizza.typeObtainer = new SpeechObtainer(asr, 1, 5000);
Xpizza.typeObtainer.setGrammar("pizza_type", "", "result.interpretation.input", dft_min, dft_confirm, true);
Xpizza.typeObtainer.setTopSound("GP-SpecialtyorCustom");
Xpizza.typeObtainer.setBadSound("GP-NI");
Xpizza.typeObtainer.addItemAlias("^Specialty$,^Specialty\\s*pizza$", "Specialty");
Xpizza.typeObtainer.addItemAlias("^pick", "Custom");
X
X
X/***************** Which Specialty? *****************/
Xpizza.specialtyObtainer = new SpeechObtainer(asr, 1, 5000);
Xpizza.specialtyObtainer.setGrammar("pizza_specialty", "", "result.interpretation.input", dft_min, dft_confirm, true);
Xpizza.specialtyObtainer.setTopSound("GP-SpecialtyList");
Xpizza.specialtyObtainer.setBadSound("GP-NI");
Xpizza.specialtyObtainer.addItemAlias("^Hawaii,^Hawaiian", "Hawaiian");
Xpizza.specialtyObtainer.addItemAlias("^Meat", "MeatLovers");
Xpizza.specialtyObtainer.addItemAlias("Pickle,^World", "Pickle");
Xpizza.specialtyObtainer.addItemAlias("^Salvador,^Dolly,^Dali", "Dali");
Xpizza.specialtyObtainer.addItemAlias("^Veg", "Vegetarian");
X
X
X/***************** What Toppings? *****************/
Xpizza.toppingsObtainer = new SpeechObtainer(asr, 1, 5000);
Xpizza.toppingsObtainer.setGrammar("pizza_toppings", "", "result.interpretation.input", dft_min, dft_confirm, true);
Xpizza.toppingsObtainer.setTopSound("GP-Toppings");
Xpizza.toppingsObtainer.setBadSound("GP-NI");
Xpizza.toppingsObtainer.addItemAlias("anchovie,anchovies", "anchovies");
Xpizza.toppingsObtainer.addItemAlias("artichoke,artichockes", "artichoke");
Xpizza.toppingsObtainer.addItemAlias("canadian\\s*bacon", "canadianbacon");
Xpizza.toppingsObtainer.addItemAlias("everything", "everything");
Xpizza.toppingsObtainer.addItemAlias("extra\\s*cheese", "extracheese");
Xpizza.toppingsObtainer.addItemAlias("garlic", "garlic");
Xpizza.toppingsObtainer.addItemAlias("goat\\s*cheese", "goatcheese");
Xpizza.toppingsObtainer.addItemAlias("bell\\s*pepper,bell\\s*peppers", "bellpepper");
Xpizza.toppingsObtainer.addItemAlias("mango", "mango");
Xpizza.toppingsObtainer.addItemAlias("mushroom,mushrooms", "mushroom");
Xpizza.toppingsObtainer.addItemAlias("olives", "olives");
Xpizza.toppingsObtainer.addItemAlias("onion,onions", "onions");
Xpizza.toppingsObtainer.addItemAlias("pepperoni", "pepperoni");
Xpizza.toppingsObtainer.addItemAlias("pickle,pickles", "pickle");
Xpizza.toppingsObtainer.addItemAlias("pineapple", "pineapple");
Xpizza.toppingsObtainer.addItemAlias("salami", "salami");
Xpizza.toppingsObtainer.addItemAlias("sausage", "sausage");
Xpizza.toppingsObtainer.addItemAlias("shrimp", "shrimp");
Xpizza.toppingsObtainer.addItemAlias("spinich", "spinich");
Xpizza.toppingsObtainer.addItemAlias("ham", "ham");
X
X/***************** Change Delivery Or Size Or Crust, Add/Rem Toppings Or Start Over *****************/
Xpizza.arsoObtainer = new SpeechObtainer(asr, 1, 5000);
Xpizza.arsoObtainer.setGrammar("pizza_arso", "", "result.interpretation.input", dft_min, 50, true);
Xpizza.arsoObtainer.setTopSound("GP-ARSO");
Xpizza.arsoObtainer.setBadSound("GP-NI");
Xpizza.arsoObtainer.addItemAlias("^delivery$", "delivery");
Xpizza.arsoObtainer.addItemAlias("^size$", "size");
Xpizza.arsoObtainer.addItemAlias("^crust$", "crust");
Xpizza.arsoObtainer.addItemAlias("^start\\s*over$", "startover");
Xpizza.arsoObtainer.addItemAlias("^add\\s*", "add_topping");
Xpizza.arsoObtainer.addItemAlias("^remove\\s*", "rem_topping");
X
X/***************** Yes? No? Maybe So? *****************/
Xpizza.yesnoObtainer = new SpeechObtainer(asr, 1, 5000);
Xpizza.yesnoObtainer.setGrammar("pizza_yesno", "", "result.interpretation.input", dft_min, 20, true);
Xpizza.yesnoObtainer.setBadSound("GP-NI");
Xpizza.yesnoObtainer.addItemAlias("^yes,^correct", "yes");
Xpizza.yesnoObtainer.addItemAlias("^no", "no");
X
X/***************** Get Some Information *****************/
Xpizza.get = function(params, confirm) {
X for(;;) {
X if (!session.ready()) {
X return false;
X }
X var main_items = params.run();
X if (confirm && params.needConfirm) {
X pizza.yesnoObtainer.setTopSound("Confirm" + main_items[0]);
X var items = pizza.yesnoObtainer.run();
X if (items[0] == "yes") {
X break;
X }
X } else {
X break;
X }
X }
X
X return main_items;
X};
X
X/***************** Is This Right? *****************/
Xpizza.check = function () {
X if (!session.ready()) {
X return false;
X }
X asr.streamFile("GP-You_ordered_a");
X asr.streamFile(pizza.size);
X asr.streamFile(pizza.crust);
X if (pizza.type == "Specialty") {
X asr.streamFile(pizza.specialty);
X asr.streamFile("pizza");
X } else {
X asr.streamFile("pizza");
X asr.streamFile("GP-With");
X for (key in pizza.toppings) {
X if (pizza.toppings[key] == "add") {
X asr.streamFile(key);
X }
X }
X
X }
X
X pizza.yesnoObtainer.setTopSound("GP-WasThisRight");
X items = pizza.yesnoObtainer.run();
X return items[0] == "yes" ? true : false;
X};
X
X/***************** Let's Remove The Toppings *****************/
Xpizza.clearToppings = function() {
X if (!session.ready()) {
X return false;
X }
X if (pizza.toppings) {
X delete pizza.toppings;
X }
X pizza.have_toppings = false;
X pizza.toppings = new Array();
X}
X
X/***************** Clean Slate *****************/
Xpizza.init = function() {
X if (!session.ready()) {
X return false;
X }
X pizza.add_rem = "add";
X pizza.order = pizza.size = pizza.crust = pizza.type = false;
X pizza.toppingsObtainer.setTopSound("GP-Toppings");
X pizza.specialty = false;
X pizza.clearToppings();
X pizza.said_greet = false;
X}
X
X/***************** Welcome! *****************/
Xpizza.greet = function () {
X if (!session.ready()) {
X return false;
X }
X if (!pizza.said_greet) {
X asr.streamFile("GP-Greeting");
X pizza.said_greet = true;
X }
X};
X
X/***************** Collect Order Type *****************/
Xpizza.getOrder = function() {
X if (!session.ready()) {
X return false;
X }
X if (!pizza.order) {
X var items = pizza.get(pizza.orderObtainer, true);
X pizza.order = items[0];
X }
X};
X
X/***************** Collect Size *****************/
Xpizza.getSize = function() {
X if (!session.ready()) {
X return false;
X }
X if (!pizza.size) {
X var items = pizza.get(pizza.sizeObtainer, true);
X pizza.size = items[0];
X }
X};
X
X/***************** Collect Crust *****************/
Xpizza.getCrust = function() {
X if (!session.ready()) {
X return false;
X }
X if (!pizza.crust) {
X var items = pizza.get(pizza.crustObtainer, true);
X pizza.crust = items[0];
X }
X};
X
X/***************** Collect Pizza Type *****************/
Xpizza.getType = function() {
X if (!session.ready()) {
X return false;
X }
X if (!pizza.type) {
X var items = pizza.get(pizza.typeObtainer, true);
X pizza.type = items[0];
X }
X};
X
X/***************** Collect Toppings *****************/
Xpizza.getToppings = function() {
X if (!session.ready()) {
X return false;
X }
X if (pizza.type == "Specialty" && !pizza.specialty) {
X var items = pizza.get(pizza.specialtyObtainer, true);
X pizza.specialty = items[0];
X pizza.have_toppings = true;
X } else if (!pizza.have_toppings) {
X toppings = pizza.get(pizza.toppingsObtainer, false);
X for(x = 0; x < toppings.length; x++) {
X pizza.toppings[toppings[x]] = pizza.add_rem;
X }
X pizza.have_toppings = true;
X }
X};
X
X/***************** Modify Pizza If You Don't Like It *****************/
Xpizza.fix = function() {
X if (!session.ready()) {
X return false;
X }
X asr.streamFile("GP-Wanted-No");
X arso = pizza.get(pizza.arsoObtainer, false);
X for (x = 0; x < arso.length; x++) {
X if (arso[x] == "delivery") {
X pizza.order = false;
X } else if (arso[x] == "size") {
X pizza.size = false;
X } else if (arso[x] == "crust") {
X pizza.crust = false;
X } else if (arso[x] == "startover") {
X pizza.init();
X } else {
X if (pizza.type == "Specialty") {
X asr.streamFile("GP-ChangeSpec");
X pizza.type = false;
X pizza.clearToppings();
X } else {
X pizza.have_toppings = false;
X if (arso[x] == "add_topping") {
X pizza.add_rem = "add";
X pizza.toppingsObtainer.setTopSound("GP-Adding");
X } else {
X pizza.add_rem = "rem";
X pizza.toppingsObtainer.setTopSound("GP-Remove");
X }
X }
X }
X }
X};
X
X/***************** Tie It All Together *****************/
Xpizza.run = function() {
X pizza.init();
X
X for(;;) {
X if (!session.ready()) {
X break;
X }
X pizza.greet();
X pizza.getOrder();
X pizza.getSize();
X pizza.getCrust();
X pizza.getType();
X pizza.getToppings();
X
X if (pizza.check()) {
X asr.streamFile(pizza.order);
X break;
X } else {
X pizza.fix();
X }
X }
X};
X
X/***************** Begin Program *****************/
Xsession.answer();
Xpizza.run();
Xasr.stop();
4bb18679aa511755730e631282a8bb61
echo x - freeswitch-pizzademo/distinfo
sed 's/^X//' >freeswitch-pizzademo/distinfo << 'a4b53054b0d3f4d03a0da9d198a3b168'
XMD5 (pizza_gram.tar.gz) = dc10f21c8d6bd708b7deae9f18a82b92
XSHA256 (pizza_gram.tar.gz) = e713406834ba40fe07c69b84f042fcb27493c15bc6b51133418527bc7a818027
XSIZE (pizza_gram.tar.gz) = 1053
XMD5 (pizza_sounds.tar.gz) = dacfde8879da8dd0e0542069e5cba6a2
XSHA256 (pizza_sounds.tar.gz) = 606f736625b7f331e219e10460029c8e0b0e58136feeddde976a0dcc68a97bef
XSIZE (pizza_sounds.tar.gz) = 1498679
a4b53054b0d3f4d03a0da9d198a3b168
echo x - freeswitch-pizzademo/pkg-descr
sed 's/^X//' >freeswitch-pizzademo/pkg-descr << '378620611b62ea92ef547ff42cd3378a'
XFreeSwitch PockectSphinx Pizza Demo
378620611b62ea92ef547ff42cd3378a
echo x - freeswitch-pizzademo/pkg-plist
sed 's/^X//' >freeswitch-pizzademo/pkg-plist << 'fc61f57755a875b77bd4088c25b7cb00'
Xfreeswitch/grammar/pizza_arso.gram
Xfreeswitch/grammar/pizza_crust.gram
Xfreeswitch/grammar/pizza_order.gram
Xfreeswitch/grammar/pizza_size.gram
Xfreeswitch/grammar/pizza_specialty.gram
Xfreeswitch/grammar/pizza_toppings.gram
Xfreeswitch/grammar/pizza_type.gram
Xfreeswitch/grammar/pizza_yesno.gram
Xfreeswitch/scripts/javascript/js_modules/SpeechTools.jm
Xfreeswitch/scripts/javascript/ps_pizza.js
Xfreeswitch/sounds/pizza/GP-DeliveryorTakeout.wav
Xfreeswitch/sounds/pizza/extracheese.wav
Xfreeswitch/sounds/pizza/garlic.wav
Xfreeswitch/sounds/pizza/Pickle.wav
Xfreeswitch/sounds/pizza/ConfirmDali.wav
Xfreeswitch/sounds/pizza/ConfirmStartOver.wav
Xfreeswitch/sounds/pizza/MeatLovers.wav
Xfreeswitch/sounds/pizza/TotallyHumongous.wav
Xfreeswitch/sounds/pizza/ConfirmPickle.wav
Xfreeswitch/sounds/pizza/goatcheese.wav
Xfreeswitch/sounds/pizza/Small.wav
Xfreeswitch/sounds/pizza/canadianbacon.wav
Xfreeswitch/sounds/pizza/ham.wav
Xfreeswitch/sounds/pizza/Medium.wav
Xfreeswitch/sounds/pizza/ConfirmHawaiian.wav
Xfreeswitch/sounds/pizza/GP-ChangeSpec.wav
Xfreeswitch/sounds/pizza/ConfirmCustom.wav
Xfreeswitch/sounds/pizza/ConfirmTotallyHumongous.wav
Xfreeswitch/sounds/pizza/pickles.wav
Xfreeswitch/sounds/pizza/ConfirmMedium.wav
Xfreeswitch/sounds/pizza/olives.wav
Xfreeswitch/sounds/pizza/ConfirmPan.wav
Xfreeswitch/sounds/pizza/Vegetarian.wav
Xfreeswitch/sounds/pizza/GP-WasThisRight.wav
Xfreeswitch/sounds/pizza/shrimp.wav
Xfreeswitch/sounds/pizza/ExtraLarge.wav
Xfreeswitch/sounds/pizza/HandTossed.wav
Xfreeswitch/sounds/pizza/GP-Wanted-No.wav
Xfreeswitch/sounds/pizza/salami.wav
Xfreeswitch/sounds/pizza/GP-SpecialtyList.wav
Xfreeswitch/sounds/pizza/GP-Crust.wav
Xfreeswitch/sounds/pizza/ConfirmExtraLarge.wav
Xfreeswitch/sounds/pizza/Pan.wav
Xfreeswitch/sounds/pizza/GP-SpecialtyorCustom.wav
Xfreeswitch/sounds/pizza/Hawaiian.wav
Xfreeswitch/sounds/pizza/artichoke.wav
Xfreeswitch/sounds/pizza/Dali.wav
Xfreeswitch/sounds/pizza/ConfirmLarge.wav
Xfreeswitch/sounds/pizza/ConfirmHandTossed.wav
Xfreeswitch/sounds/pizza/ConfirmPickup.wav
Xfreeswitch/sounds/pizza/spinach.wav
Xfreeswitch/sounds/pizza/everything.wav
Xfreeswitch/sounds/pizza/Delivery.wav
Xfreeswitch/sounds/pizza/GP-NI.wav
Xfreeswitch/sounds/pizza/sausage.wav
Xfreeswitch/sounds/pizza/ConfirmVegetarian.wav
Xfreeswitch/sounds/pizza/mango.wav
Xfreeswitch/sounds/pizza/GP-Remove.wav
Xfreeswitch/sounds/pizza/bellpepper.wav
Xfreeswitch/sounds/pizza/GP-You_ordered_a.wav
Xfreeswitch/sounds/pizza/mushroom.wav
Xfreeswitch/sounds/pizza/Thin.wav
Xfreeswitch/sounds/pizza/onions.wav
Xfreeswitch/sounds/pizza/pizza.wav
Xfreeswitch/sounds/pizza/ConfirmRemove.wav
Xfreeswitch/sounds/pizza/ConfirmNone.wav
Xfreeswitch/sounds/pizza/pineapple.wav
Xfreeswitch/sounds/pizza/GP-ARSO.wav
Xfreeswitch/sounds/pizza/GP-Size.wav
Xfreeswitch/sounds/pizza/GP-Adding.wav
Xfreeswitch/sounds/pizza/GP-Toppings.wav
Xfreeswitch/sounds/pizza/GP-Greeting.wav
Xfreeswitch/sounds/pizza/ConfirmDelivery.wav
Xfreeswitch/sounds/pizza/ConfirmThin.wav
Xfreeswitch/sounds/pizza/ConfirmSpeciality.wav
Xfreeswitch/sounds/pizza/ConfirmSmall.wav
Xfreeswitch/sounds/pizza/ConfirmMeatLovers.wav
Xfreeswitch/sounds/pizza/pepperoni.wav
Xfreeswitch/sounds/pizza/GP-With.wav
Xfreeswitch/sounds/pizza/Large.wav
Xfreeswitch/sounds/pizza/Pickup.wav
Xfreeswitch/sounds/pizza/GP-NoDeliveryorTake-out.wav
Xfreeswitch/sounds/pizza/anchovies.wav
Xfreeswitch/sounds/pizza/Crust.wav
X at dirrm freeswitch/sounds/pizza
X at dirrm freeswitch/sounds
X at dirrm freeswitch/scripts/javascript/js_modules
X at dirrm freeswitch/scripts/javascript
X at exec mkdir -p %D/freeswitch/scripts/javascript/js_modules
X at exec mkdir -p %D/freeswitch/scripts/javascript
fc61f57755a875b77bd4088c25b7cb00
echo x - freeswitch-pizzademo/Makefile
sed 's/^X//' >freeswitch-pizzademo/Makefile << 'fbe7ee448e90adbbce26752d0a254c89'
X# Ports collection makefile for: freeswitch pizza demo
X# Date created: september , 2009
X# Whom: Richard Neese <r.neese at gmail.com>
X#
X# $FreeBSD$
X#
X
XPORTNAME= freeswitch-pizzademo
XPORTVERSION= 0.1
XCATEGORIES= audio
XMASTER_SITES= http://files.freeswitch.org/:source1 \
X http://dl.getdropbox.com/u/152504/:source2
XDISTFILES= pizza_gram.tar.gz:source1 \
X pizza_sounds.tar.gz:source1
X
XMAINTAINER= r.neese at gmail.com
XCOMMENT= FreeSwitch pizza demo
X
XRUN_DEPENDS= ${LOCALBASE}/freeswitch/bin/freeswitch:${PORTSDIR}/net/freeswitch
X
XNO_BUILD= yes
X
Xdo-install:
X @${CP} -R files/* ${LOCALBASE}/share/freeswitch/scripts
X @${TAR} -xvzf ${DISTDIR}/pizza_gram.tar.gz -C ${LOCALBASE}/share/freeswitch/grammar
X @${TAR} -xzvf ${DISTDIR}/pizza_sounds.tar.gz -C ${LOCALBASE}/share/freeswitch/sounds
X @${CHOWN} -R freeswitch:freeswitch /$(LOCALBASE)/share/freeswitch/scripts
X @${CHOWN} -R freeswitch:freeswitch /$(LOCALBASE)/share/freeswitch/grammar
X @${CHOWN} -R freeswitch:freeswitch /$(LOCALBASE)/share/freeswitch/sounds
X
X.include <bsd.port.mk>
fbe7ee448e90adbbce26752d0a254c89
exit
--- fspizza.shar ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list