private static PhoneModel PhoneModel(PhoneInfo info) { var dict = new Dictionary <ModelIdentity, PhoneModel>() { { new ModelIdentity("P6211", "42-7D-8F-D5-A7-F2-27-82-0D-5B-11-BF-8C-6F-76-70-C0-A0-62-2C-C6-1B-A9-5A-AE-E1-8F-75-17-FC-0B-77"), Lumia.PhoneModel.Cityman }, { new ModelIdentity("P6170", "42-7D-8F-D5-A7-F2-27-82-0D-5B-11-BF-8C-6F-76-70-C0-A0-62-2C-C6-1B-A9-5A-AE-E1-8F-75-17-FC-0B-77"), Lumia.PhoneModel.Hapanero }, { new ModelIdentity("P6218", "9C-FA-9A-DB-10-1C-E4-1E-C5-E0-B4-BF-58-6B-CD-37-A4-BA-93-1F-D9-75-F9-99-52-48-5F-EF-0E-7B-DF-A4"), Lumia.PhoneModel.Talkman }, }; var rkhStr = BitConverter.ToString(info.Rkh); var name = info.Plat.Name.Replace("_ATT", ""); var key = new ModelIdentity(name, rkhStr); return(dict[key]); }
public VoiceTestDefinition( ModelIdentity model, string text, string voiceTestKind) { this.Model = model; this.Text = text; this.VoiceTestKind = voiceTestKind; }
public void CreateVoiceSynthesis(string name, string description, string locale, string inputTextPath, Guid modelId) { Console.WriteLine("Creating batch synthesiss."); var properties = new Dictionary <string, string> { { "ConcatenateResult", "true" } }; var model = ModelIdentity.Create(modelId); var voiceSynthesisDefinition = VoiceSynthesisDefinition.Create(name, description, locale, model, properties); var submitResponse = VoiceAPIHelper.SubmitVoiceSynthesis(voiceSynthesisDefinition, inputTextPath, VoiceSynthesisUrl, this.subscriptionKey); }
public async Task <Uri> CreateVoiceSynthesis(string name, string description, string locale, string inputTextPath, Guid modelId, bool concatenateResult) { Console.WriteLine("Creating batch synthesiss."); var properties = new Dictionary <string, string>(); if (concatenateResult) { properties.Add("ConcatenateResult", "true"); } var model = ModelIdentity.Create(modelId); var voiceSynthesisDefinition = VoiceSynthesisDefinition.Create(name, description, locale, model, properties); using (var submitResponse = VoiceAPIHelper.SubmitVoiceSynthesis(voiceSynthesisDefinition, inputTextPath, VoiceSynthesisUrl, this.subscriptionKey)) { return(await GetLocationFromPostResponseAsync(submitResponse).ConfigureAwait(false)); } }
public void CreateBatchSynthesis(string name, string description, string locale, string inputTextPath, Guid modelId, string azureStorageConnectionString) { Console.WriteLine($"upload text to azure storage blob : {inputTextPath}"); var containerName = "voicesynthesisinputfiles"; CloudStorageAccount storageAccount = CloudStorageAccount.Parse(azureStorageConnectionString); var blobClient = storageAccount.CreateCloudBlobClient(); var containerReference = blobClient.GetContainerReference(containerName); containerReference.CreateIfNotExists(); var fileName = $"SubscriptionKey_{Guid.NewGuid().ToString()}.txt"; StorageHelper.UploadFileAsync(containerReference, fileName, inputTextPath); var textUrl = StorageHelper.GetBlobSas(blobClient, containerName, fileName, DateTime.MaxValue); Console.WriteLine("Creating batch synthesiss."); var model = ModelIdentity.Create(modelId); var batchSynthesisDefinition = BatchSynthesisDefinition.Create(name, description, locale, new Uri($"{ textUrl }"), model); var submitResponse = VoiceAPIHelper.Submit <BatchSynthesisDefinition>(batchSynthesisDefinition, VoiceSynthesisUrl, this.subscriptionKey); }
private async Task StartBatchTranscriptionJobAsync(IEnumerable <Message> messages, string jobName) { if (messages == null || !messages.Any()) { Logger.LogError($"Invalid service bus message(s)."); return; } var fetchingDelay = GetInitialFetchingDelay(messages.Count()); var locationString = string.Empty; var serviceBusMessages = messages.Select(message => JsonConvert.DeserializeObject <ServiceBusMessage>(Encoding.UTF8.GetString(message.Body))); try { var properties = GetTranscriptionPropertyBag(); var sasUrls = new List <string>(); var audioFileInfos = new List <AudioFileInfo>(); foreach (var serviceBusMessage in serviceBusMessages) { var sasUrl = StorageConnectorInstance.CreateSas(serviceBusMessage.Data.Url); sasUrls.Add(sasUrl); audioFileInfos.Add(new AudioFileInfo(serviceBusMessage.Data.Url.AbsoluteUri, serviceBusMessage.RetryCount)); } ModelIdentity modelIdentity = null; if (Guid.TryParse(StartTranscriptionEnvironmentVariables.CustomModelId, out var customModelId)) { modelIdentity = ModelIdentity.Create(StartTranscriptionEnvironmentVariables.AzureSpeechServicesRegion, customModelId); } var transcriptionDefinition = TranscriptionDefinition.Create(jobName, "StartByTimerTranscription", Locale, sasUrls, properties, modelIdentity); var transcriptionLocation = await BatchClient.PostTranscriptionAsync( transcriptionDefinition, HostName, SubscriptionKey, Logger).ConfigureAwait(false); Logger.LogInformation($"Location: {transcriptionLocation}"); var transcriptionMessage = new TranscriptionStartedMessage( transcriptionLocation.AbsoluteUri, jobName, Locale, modelIdentity != null, audioFileInfos, 0, 0); await ServiceBusUtilities.SendServiceBusMessageAsync(FetchQueueClientInstance, transcriptionMessage.CreateMessageString(), Logger, fetchingDelay).ConfigureAwait(false); } catch (WebException e) { if (BatchClient.IsThrottledOrTimeoutStatusCode(((HttpWebResponse)e.Response).StatusCode)) { var errorMessage = $"Throttled or timeout while creating post. Error Message: {e.Message}"; Logger.LogError(errorMessage); await RetryOrFailMessagesAsync(messages, errorMessage).ConfigureAwait(false); } else { var errorMessage = $"Start Transcription in job with name {jobName} failed with WebException {e} and message {e.Message}"; Logger.LogError(errorMessage); using (var reader = new StreamReader(e.Response.GetResponseStream())) { var responseMessage = await reader.ReadToEndAsync().ConfigureAwait(false); errorMessage += "\nResponse message:" + responseMessage; } await WriteFailedJobLogToStorageAsync(serviceBusMessages, errorMessage, jobName).ConfigureAwait(false); } throw; } catch (TimeoutException e) { var errorMessage = $"Timeout while creating post, re-enqueueing transcription start. Message: {e.Message}"; Logger.LogError(errorMessage); await RetryOrFailMessagesAsync(messages, errorMessage).ConfigureAwait(false); throw; } catch (Exception e) { var errorMessage = $"Start Transcription in job with name {jobName} failed with exception {e} and message {e.Message}"; Logger.LogError(errorMessage); await WriteFailedJobLogToStorageAsync(serviceBusMessages, errorMessage, jobName).ConfigureAwait(false); throw; } Logger.LogInformation($"Fetch transcription queue successfully informed about job at: {jobName}"); }
protected bool Equals(ModelIdentity other) { return(string.Equals(Plat, other.Plat) && string.Equals(Rkh, other.Rkh)); }
public ExportModels(ExportCredential exportCredential) { _credential = exportCredential; _modelIdentity = GetModelIdentity(); }
public bool GenerateRvtFileFromModelDataFolder(string strModelDataPath, DataFormatVersion dataFormatVersion, string strRvtFilePath, bool bCreateLocal, bool bOverwrite, ModelIdentity centralIdentity, string centralModelFullPath) { if (File.Exists(strRvtFilePath)) { if (!bOverwrite) { return(false); } File.Delete(strRvtFilePath); } IDictionary <string, string> nonElemStreamFiles = new Dictionary <string, string>(); IDictionary <int, string> elemStreamFiles = new Dictionary <int, string>(); IDictionary <int, string> steelIncrementStreamFiles = new Dictionary <int, string>(); using (IModelDataVersionManager modelDataVersionManager = CreateModelDataVersionManager(strModelDataPath, dataFormatVersion)) { if (!modelDataVersionManager.GetLatestStreamFiles(ref nonElemStreamFiles, ref elemStreamFiles, ref steelIncrementStreamFiles)) { return(false); } } if (!RvtFile.GenerateRvtFileFromModelFolder(nonElemStreamFiles, elemStreamFiles, steelIncrementStreamFiles, dataFormatVersion, strRvtFilePath)) { return(false); } if (bCreateLocal && (object)centralIdentity != null && centralIdentity.isValid()) { try { var basicFileInfo = ReadFromRVTFile(strRvtFilePath); if (basicFileInfo != null) { basicFileInfo.AllLocalChangesSavedToCentral = false; basicFileInfo.Author = "Autodesk Revit"; basicFileInfo.CentralIdentity = ModelIdentity.NewModelIdentity; basicFileInfo.CentralPath = ""; basicFileInfo.Format = "2019"; basicFileInfo.Identity = ModelIdentity.NewModelIdentity; basicFileInfo.IsLT = false; basicFileInfo.IsSingleUserCloudModel = false; basicFileInfo.IsWorkshared = false; basicFileInfo.LocaleWhenSaved = "RUS"; basicFileInfo.OpenWorksetDefault = 1; basicFileInfo.SavedPath = ""; basicFileInfo.Username = ""; basicFileInfo.LatestCentralVersion = 1; basicFileInfo.UniqueDocumentVersionSequence = 1; basicFileInfo.UniqueDocumentVersionGUID = GUIDValue.NewGUIDValue(); basicFileInfo.LatestCentralEpisodeGUID = GUIDValue.NewGUIDValue(); basicFileInfo.WorksharingState = WorksharingState.WS_Central; } } catch (Exception ex) { throw; } } return(true); }