Exemple #1
0
        /// <summary>
        /// This funtion makes API call to get SMS
        /// </summary>
        public RecognitionObj.RootObject speechToText(string parXspeechContext,
                                                        string parXArgs,
                                                        string parSpeechFilePath,
                                                        bool parChunked)
        {
            var audioFileStream = new FileStream(parSpeechFilePath, FileMode.Open, FileAccess.Read);
            BinaryReader reader = new BinaryReader(audioFileStream);
            byte[] binaryData = reader.ReadBytes((int)audioFileStream.Length);
            reader.Close();
            audioFileStream.Close();

            if (binaryData.Length > 0)
            {
                APIRequest apiRequest = new APIRequest("speechToText");

                apiRequest.accept = "application/json";
                apiRequest.addHeaders("X-SpeechContext", parXspeechContext);
                apiRequest.addHeaders("X-Arg", parXArgs);
                apiRequest.contentType = "audio/wav";
                apiRequest.accept = "application/json";
                apiRequest.SendChunked = parChunked;
                apiRequest.binaryData = binaryData;

                if (apiService.post(apiRequest))
                {
                    RecognitionObj robj = new RecognitionObj();
                    return robj.deserializeRecognition(apiService.apiResponse.getResponseData());
                }
                throw new Exception(apiService.errorResponse);
            }
            throw new Exception("No audio data.");
        }
Exemple #2
0
        public AdsObj.RootObject GetAds(string category, string udid, string userAgent)
        {
            try
            {
                APIRequest apiRequest = new APIRequest("ads?Category=" + category);

                apiRequest.accept = "application/json";
                apiRequest.addHeaders("Udid", udid);
                apiRequest.userAgent = userAgent;

                if (apiService.get(apiRequest))
                {
                    return new AdsObj().deserializeAdsObj(apiService.apiResponse.getResponseData());
                }

            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }
            return null;
        }
Exemple #3
0
        /// <summary>
        /// This funtion makes API call to get SMS
        /// </summary>
        public RecognitionObj.RootObject speechToTextCustom(string mimeData,
                                                            string XspeechContext,
                                                            string XArgs,
                                                            string SpeechFilePath,
                                                            string xdictionaryContent,
                                                            string xgrammerContent)
        {
            APIRequest apiRequest = new APIRequest("speechToTextCustom");

            string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x");

            apiRequest.accept = "application/json";
            apiRequest.addHeaders("Content-Language", "en-us");
            apiRequest.addHeaders("X-Arg", XArgs);
            apiRequest.contentType = "multipart/x-srgs-audio; " + "boundary=" + boundary;
            apiRequest.accept = "application/json";
            apiRequest.binaryData = getTotalByte(boundary, xdictionaryContent, SpeechFilePath, xgrammerContent);

            if (apiService.post(apiRequest))
            {
                RecognitionObj robj = new RecognitionObj();
                return robj.deserializeRecognition(apiService.apiResponse.getResponseData());
            }

            throw new Exception(apiService.errorResponse);
        }
        /// <summary>
        /// This function makes API call to get contacts operation
        /// </summary>
        public QuickContactObj.RootObject getContacts(string search)
        {
            APIRequest apiRequest = new APIRequest("contacts?" + "search=" + search);

            apiRequest.accept = "application/json";
            apiRequest.addHeaders("x-fields", "shallow");

            if (apiService.get(apiRequest))
            {
                var contact = new QuickContactObj();
                return contact.deserializeQuickContactsObj(apiService.apiResponse.getResponseData());
            }

            throw new Exception(apiService.errorResponse);
        }