Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            // Set the voice property.
            //tropo.Voice = Voice.UsEnglishMale_Steven;

            Say say = new Say("Please record your 45 second message after the 32 beeps, press pound when complete.");

            tropo.Say(say);

            StartRecording startRecording = new StartRecording();

            startRecording.AsyncUpload = true;
            tropo.StartRecording(false, AudioFormat.Wav, Method.Post, "http://192.168.26.88:8080/FileUpload/uploadFile", "", "", "", "plain", "");

            //Say say2 = new Say("Fourscore and seven years ago our fathers brought forth, on this continent, a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived, and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting-place for those who here gave their lives, that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we cannot dedicate, we cannot consecrate—we cannot hallow—this ground. The brave men, living and dead, who struggled here, have consecrated it far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they here gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom, and that government of the people, by the people, for the people, shall not perish from the earth.");
            Say say2 = new Say("I love beijing, hi tropo new version");

            tropo.Say(say2);


            tropo.StopRecording();


            Say say3 = new Say("is it wait 8 seconds?");

            tropo.Say(say3);

            tropo.RenderJSON(Response);
        }
        /// <summary>
        /// Click event handeler for Record Button
        /// </summary>
        /// <param name="sender">Object triggering the summoning event</param>
        /// <param name="e"><see cref="EventArgs"/> passed from sender</param>
        private void record_button_Click(object sender, EventArgs e)
        {
            if (!record_button_toggle)
            {
                if (System.IO.File.Exists(FilePath))
                {
                    DialogResult overwriteFileCheck = MessageBox.Show("The specified file already exists!\n\nRecording now will overwrite that file's " +
                                                                      "contents. Do you want to begin recording anyway?", "Overwrite File Warning",
                                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                }

                // Change button function to Stop Recording and Signals Start Recording
                record_button.Image = Properties.Resources.stop;
                StartRecording?.Invoke(this, new EventArgs());

                timeIndex_label.ForeColor = Color.Firebrick;
                play_button.Enabled       = false;
            }
            else
            {
                record_button.Image = Properties.Resources.record;
                StopRecording?.Invoke(this, new EventArgs());

                timeIndex_label.ForeColor = System.Drawing.SystemColors.ControlText;
                play_button.Enabled       = true;
            }

            record_button_toggle = !record_button_toggle;
        }
Esempio n. 3
0
        public void testCallUsingCallObject()
        {
            Tropo tropo = new Tropo();

            IDictionary <string, string> headers = new Dictionary <String, String>();

            headers.Add("foo", "bar");
            headers.Add("bling", "baz");

            StartRecording recording = new StartRecording(AudioFormat.Mp3, Method.Post, "http://blah.com/recordings/1234.wav", "jose", "password");

            List <String> to = new List <String>(1);

            to.Add("3055195825");

            Call call = new Call();

            call.Recording     = recording;
            call.Headers       = headers;
            call.Timeout       = 10;
            call.AnswerOnMedia = false;
            call.Channel       = Channel.Text;
            call.Network       = Network.SMS;
            call.To            = to;
            call.From          = "3055551212";

            tropo.Call(call);
            Assert.AreEqual(this.callJsonAllOptions, tropo.RenderJSON());
        }
Esempio n. 4
0
        /**
         * Initialize a "startRecording" command.
         *
         * @param  Key[]
         * @return this
         */
        public Voice StartRecording(params Key[] keys)
        {
            // initialize start recording
            StartRecording startRecording = new StartRecording(keys);

            // push to our commands
            this.rootArray.Add(startRecording.GetAction());

            return(this);
        }
Esempio n. 5
0
        public void testCallUseAllOptions()
        {
            Tropo tropo = new Tropo();

            IDictionary <string, string> headers = new Dictionary <String, String>();

            headers.Add("foo", "bar");
            headers.Add("bling", "baz");

            StartRecording recording = new StartRecording(AudioFormat.Mp3, Method.Post, "http://blah.com/recordings/1234.wav", "jose", "password");

            tropo.Call("3055195825", "3055551212", Network.SMS, Channel.Text, false, 10, headers, recording);
            Assert.AreEqual(this.callJsonAllOptions, tropo.RenderJSON());
        }
Esempio n. 6
0
 void BtnStartClick(object sender, EventArgs e)
 {
     btnStart.Enabled = false;
     btnPause.Enabled = true;
     btnStop.Enabled = true;
     
     
     // this.Cmdlet.NoUI = true;
     // UiaHelper.ProcessingTranscript(this.Cmdlet)
     if (!Cmdlet.Paused) {
         StartRecording startRec = new StartRecording(StartRecordingMethod);
         Invoke(startRec, Cmdlet);
     }
     Cmdlet.Paused = false;
 }
        public void testNewStartRecordingObject()
        {
            StartRecording startRecording = new StartRecording();

            startRecording.Format   = AudioFormat.Mp3;
            startRecording.Method   = Method.Post;
            startRecording.Url      = "http://blah.com/recordings/1234.wav";
            startRecording.Username = "******";
            startRecording.Password = "******";

            Tropo tropo = new Tropo();

            tropo.StartRecording(startRecording);

            Assert.AreEqual(this.startRecordingJson, renderJSONToText(tropo));
        }
Esempio n. 8
0
        void BtnStartClick(object sender, EventArgs e)
        {
            btnStart.Enabled = false;
            btnPause.Enabled = true;
            btnStop.Enabled  = true;


            // this.Cmdlet.NoUI = true;
            // UiaHelper.ProcessingTranscript(this.Cmdlet)
            if (!Cmdlet.Paused)
            {
                StartRecording startRec = new StartRecording(StartRecordingMethod);
                Invoke(startRec, Cmdlet);
            }
            Cmdlet.Paused = false;
        }
Esempio n. 9
0
        static void TestVoice()
        {
            Header headers = new Header(
                new string[] { "x-sbc-from", "\"username\"<sip:[email protected]>;tag=2a648c6e" },
                new string[] { "x-sbc-allow", "BYE" },
                new string[] { "x-sbc-user-agent", "sipgw-1.0" },
                new string[] { "x-sbc-contact", "<sip:[email protected]:16000>" },
                new string[] { "Content-Length", "247" },
                new string[] { "To", "<sip:[email protected]:5060>" },
                new string[] { "Contact", "<sip:[email protected]:5060>" },
                new string[] { "x-sbc-request-uri", "sip:[email protected]:5060" },
                new string[] { "x-sbc-call-id", "OWE0OGFkMTE1ZGY4NTI1MmUzMjc1M2Y3Y2ExMzc2YhG." },
                new string[] { "x-sid", "39f4688b8896f024f3a3aebd0cfb40b2" },
                new string[] { "x-sbc-cseq", "1 INVITE" },
                new string[] { "x-sbc-max-forwards", "70" },
                new string[] { "CSeq", "2 INVITE" },
                new string[] { "Via", "SIP/2.0/UDP 66.190.50.10:5060;received=10.6.60.100" },
                new string[] { "x-sbc-record-route", "<sip:190.40.250.230:5061;r2=on;lr;ftag=2a648c6e>" },
                new string[] { "Call-ID", "0-13c4-4b7d8ff7-1c3c1b82-7935-1d10b081" },
                new string[] { "Content-Type", "application/sdp" },
                new string[] { "x-sbc-to", "<sip:[email protected]:5060>" },
                new string[] { "From", "<sip:[email protected]:5060>;tag=0-13c4-4b7d8ff7-1c3c1b82-5c7b" }
                );

            Ask ask = new Ask(
                INSTANCE(
                    new Choices(
                        VALUE("1"),
                        MODE(Mode.DTMF),
                        TERMINATOR("*")
                        )
                    ),
                ATTEMPTS(10),
                BARGEIN(true),
                MIN_CONFIDENCE(10),
                NAME("foo"),
                RECOGNIZER(Recognizer.US_ENGLISH),
                REQUIRED(false),
                INSTANCE(
                    new Say("Hello World")
                    ),
                TIMEOUT(10),
                VOICE(VoiceEnum.VICTOR),
                INTER_DIGIT_TIMEOUT(10),
                SENSITIVITY(10),
                SPEECH_COMPLETE_TIMEOUT(10),
                SPEECH_INCOMPLETE_TIMEOUT(10)
                );

            Print(ask.GetAction());

            Call call = new Call(
                TO("+123456"),
                ANSWER_ON_MEDIA(false),
                CHANNEL(Channel.VOICE),
                FROM("+123456"),
                INSTANCE(headers),
                NAME("call"),
                NETWORK(Network.SIP),
                INSTANCE(
                    new Record(
                        INSTANCE(new Say(VALUE("Hello World"), ARRAY(new Say("Hello World"))))
                        )
                    ),
                REQUIRED(true),
                TIMEOUT(10),
                ALLOW_SIGNALS(true),
                INSTANCE(
                    new MachineDetection(
                        INTRODUCTION("Hello World"),
                        VOICE(VoiceEnum.VICTOR)
                        )
                    )
                );

            Print(call.GetAction());

            Choices choices = new Choices(
                VALUE("[5 DIGITS]"),
                MODE(Mode.DTMF),
                TERMINATOR("#")
                );

            Print(choices.GetAction());

            Conference conference = new Conference(
                ID("12345"),
                MUTE(false),
                NAME("conference"),
                PLAY_TONES(false),
                REQUIRED(false),
                TERMINATOR("#"),
                ALLOW_SIGNALS(false),
                INTER_DIGIT_TIMEOUT(10),
                INSTANCE(new JoinPrompt(VALUE("Please welcome the monster to the party!"))),
                INSTANCE(new LeavePrompt(VALUE("The monster has decide to depart!")))
                );

            Print(conference.GetAction());

            Hangup hangup = new Hangup();

            Print(hangup.GetAction());

            MachineDetection md = new MachineDetection(
                INTRODUCTION("Hello World"),
                VOICE(VoiceEnum.VICTOR)
                );

            Print(md.GetAction());

            Message message = new Message(
                INSTANCE(new Say("Hello World")),
                TO("+63525544787"),
                ANSWER_ON_MEDIA(false),
                CHANNEL(Channel.TEXT),
                FROM("2542562"),
                NAME("message"),
                NETWORK(Network.JABBER),
                REQUIRED(false),
                TIMEOUT(60),
                VOICE(VoiceEnum.CARMEN)
                );

            Print(message.GetAction());

            On on = new On(
                EVENT("continue"),
                NAME("event"),
                NEXT("http://openovate.com/hello.php"),
                REQUIRED(false),
                INSTANCE(new Say("Hello World")),
                INSTANCE(ask),
                INSTANCE(message),
                INSTANCE(new Wait(MILLISECONDS(3000), ALLOW_SIGNALS(true)))
                );

            Print(on.GetAction());

            Record record = new Record(
                ATTEMPTS(10),
                BARGEIN(false),
                BEEP(false),
                INSTANCE(choices),
                FORMAT(Format.MP3),
                MAX_SILENCE(10),
                MAX_TIME(60),
                METHOD("POST"),
                MIN_CONFIDENCE(10),
                NAME("recording"),
                REQUIRED(false),
                INSTANCE(new Say("Hello World")),
                TIMEOUT(10),
                INSTANCE(
                    new Transcription(
                        ID("12345"),
                        URL("https//gmail.com"),
                        EMAIL_FORMAT("format")
                        )
                    ),
                URL("http://openovate.com/recording.js"),
                USERNAME("admin"),
                PASSWORD("admin"),
                VOICE(VoiceEnum.CARLOS),
                ALLOW_SIGNALS(false),
                INTER_DIGIT_TIMEOUT(10)
                );

            Print(record.GetAction());

            Redirect redirect = new Redirect(TO("+12345"), NAME("charles"), REQUIRED(false));

            Print(redirect.GetAction());

            Reject reject = new Reject();

            Print(reject.GetAction());

            Say say = new Say(
                VALUE("Hello World"),
                AS(As.DIGITS),
                NAME("say"),
                REQUIRED(false),
                VOICE(VoiceEnum.BERNARD),
                ALLOW_SIGNALS(false)
                );

            Print(say.GetAction());

            StartRecording sr = new StartRecording(
                FORMAT(Format.MP3),
                METHOD("POST"),
                URL("http://openovate.com/recording.js"),
                USERNAME("admin"),
                PASSWORD("admin"),
                TRANSCRIPTION_ID("12345"),
                TRANSCRIPTION_EMAIL_FORMAT("format"),
                TRANSCRIPTION_OUT_URI("http://openovate.com/recording.js")
                );

            Print(sr.GetAction());

            Transfer transfer = new Transfer(
                TO("+123456"),
                ANSWER_ON_MEDIA(false),
                INSTANCE(choices),
                FROM("12345"),
                INSTANCE(headers),
                NAME("transfer"),
                INSTANCE(
                    new On(ARRAY(
                               new On(
                                   EVENT("ring"),
                                   INSTANCE(new Say("http://www.phono.com/audio/holdmusic.mp3"))
                                   ),
                               new On(
                                   EVENT("connect"),
                                   INSTANCE(say)
                                   ))
                           )
                    ),
                REQUIRED(false),
                TERMINATOR("*"),
                TIMEOUT(10),
                ALLOW_SIGNALS(false),
                INTER_DIGIT_TIMEOUT(10),
                INSTANCE(md)
                );

            Print(transfer.GetAction());

            Wait wait = new Wait(
                MILLISECONDS(500),
                ALLOW_SIGNALS(true)
                );

            Print(wait.GetAction());

            string  resultJson   = @"{""result"":{""callId"":""8a2bd2f204f4488e22c099a21e900068"",""sequence"":1,""calledid"":""6391721584130"",""sessionId"":""a1e275877b5346c576ae309cb2e6d829"",""state"":""ANSWERED"",""sessionDuration"":10,""complete"":true,""error"":null,""actions"":{""disposition"":""SUCCESS"",""interpretation"":""52521"",""xml"":""<?xml version=\""1.0\""?>\r\n<result grammar=\""[email protected]\"">\r\n    <interpretation grammar=\""[email protected]\"" confidence=\""100\"">\r\n        \r\n      <input mode=\""dtmf\"">dtmf-5 dtmf-2 dtmf-5 dtmf-2 dtmf-1<\/input>\r\n    <\/interpretation>\r\n<\/result>\r\n"",""confidence"":100,""name"":""foo"",""value"":""52521"",""utterance"":""52521"",""attempts"":1}}}";
            JObject resultParsed = JObject.Parse(resultJson);

            Result result = new Result(resultParsed);

            Print(result.GetResult());

            string  sessionJson   = @"{""session"":{""callId"":""e9d6ea5c3e1f9cdf7bd6755df792128f"",""accountId"":""357"",""headers"":{""P-Asserted-Identity"":""<sip:[email protected]>"",""Call-ID"":""[email protected]"",""Session-Expires"":""1800"",""Max-Forwards"":""67"",""CSeq"":""22885 INVITE"",""Record-Route"":""<sip:54.251.186.109:5060;transport=udp;lr>"",""User-Agent"":""ZTE Softswitch/1.0.0"",""x-sid"":""d7cb81bdeef47e5d9520e3867e99dd2e"",""From"":""09065272450 <sip:[email protected]>;tag=aa38c01-u0HM7d7ee5c02"",""Supported"":""100rel"",""Contact"":""<sip:[email protected]:5060>"",""Allow"":""INVITE"",""Via"":""SIP/2.0/UDP 54.251.186.109:5060;branch=z9hG4bK6vnl2t62s715;rport=5060;received=172.31.28.102"",""Min-SE"":""90"",""To"":""21584130 <sip:[email protected]>"",""Content-Length"":""790"",""P-Charging-Vector"":""icid-value=Netun-20161125172901-00580505"",""Content-Type"":""application/sdp""},""initialText"":null,""from"":{""name"":""09065272450"",""channel"":""VOICE"",""id"":""6309065272450"",""network"":""SIP""},""id"":""27741ecb65b5c916eeded4039ae22396"",""userType"":""HUMAN"",""to"":{""name"":""21584130"",""channel"":""VOICE"",""id"":""6391721584130"",""network"":""SIP""},""timestamp"":""2016-11-25T09:29:01.129Z""}}";
            JObject sessionParsed = JObject.Parse(sessionJson);

            Session session = new Session(sessionParsed);

            Print(session.GetSession());

            VoiceBase voice = new VoiceBase();

            voice.Say("Hello World");
            voice.Wait();

            Print(voice.Render().ToString());
        }
Esempio n. 10
0
        public void Page_Load(object sender, EventArgs args)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            Say say1 = new Say("Are you frank on windows. thanks to jerry");
            Say say2 = new Say("Are you frank on Mac.  thanks to jerry");
            Say say3 = new Say("http://192.168.26.55:8080/tropo/script/I.mp3");

            // Choices for the Ask.
            //Choices choices = new Choices("1,2,3");

            // Set up the dialog.
            //tropo.Call("sip:[email protected]:5678");

            IDictionary <string, string> headers = new Dictionary <String, String>();

            headers.Add("foo", "bar");
            headers.Add("bling", "baz");

            StartRecording recording = new StartRecording(AudioFormat.Mp3, Method.Post, "http://blah.com/recordings/1234.wav", "jose", "password");

            List <String> to = new List <String>(1);

            to.Add("sip:[email protected]:5678");
            //to.Add("sip:[email protected]:5678");

            Call call = new Call();

            call.Recording     = recording;
            call.Headers       = headers;
            call.Timeout       = 10;
            call.AnswerOnMedia = false;
            call.Channel       = Channel.Voice;
            //call.Network = Network.SMS;
            call.To = to;
            //call.From = "3055551212";
            call.MachineDetection = new MachineDetection("For the most accurate results, the introduction should be long enough to give Tropo time to detect a human or machine. The longer the introduction, the more time we have to determine how the call was answered. If the introduction is long enough to play until the voicemail beep plays, Tropo will have the most accurate detection. It takes a minimum of four seconds to determine if a call was answered by a human or machine, so introductions four seconds or shorter will always return HUMAN.");
            //call.MachineDetection = new MachineDetection();
            //call.Voice = Voice.UsEnglishFemale_Allison;
            call.Voice             = "en-us";
            call.CallbackUrl       = "";
            call.PromptLogSecurity = "";
            call.Label             = "canUseAppidASLabel";

            //tropo.Hangup();
            tropo.Call(call);
            //tropo.Call("sip:[email protected]:5678");
            tropo.Say(say1);
            //tropo.Hangup();

            //Transfer transfer = new Transfer();
            //IEnumerable<string> transferTo = new string[] { "sip:[email protected]:5678", "sip:[email protected]:5678" };
            //string from = "87473032";
            ////string[] names = { "sip:[email protected]:5678", "sip:[email protected]:5678" };
            ////to = (IEnumerable<string>)names.GetEnumerator();
            //transfer.To = transferTo;
            //transfer.From = from;
            ////transfer.AnswerOnMedia = true;
            ////On on = new On();
            ////on.Event = Event.Ring;
            ////on.Next = "http://192.168.26.55:8080/tropo/script/I.mp3";
            ////on.Next = "http://freewavesamples.com/files/Kawai-K5000W-AddSquare-C4.wav";
            ////on.Say = say3;
            ////transfer.On = on;
            //tropo.Transfer(transfer);

            ////tropo.On("ring", "http://freewavesamples.com/files/Kawai-K5000W-AddSquare-C4.wav", say3);


            ////tropo.On()

            ////tropo.Call("sip:[email protected]:5678");
            ////tropo.Say(say2);
            ////tropo.Hangup();

            tropo.On("continue", "TropoResult.aspx", new Say("call test result"));

            tropo.RenderJSON(Response);
        }