mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Fix Azure voice refresh
This commit is contained in:
parent
ca9fa80b4b
commit
2dddf56a61
@ -2176,7 +2176,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
};
|
};
|
||||||
|
|
||||||
var path = Path.GetDirectoryName(videoFileName);
|
var path = Path.GetDirectoryName(videoFileName);
|
||||||
// try to locate subtitle file for the input vide file
|
// try to locate subtitle file for the input video file
|
||||||
var subtitleFile = FileUtil.TryLocateSubtitleFile(path, videoFileName);
|
var subtitleFile = FileUtil.TryLocateSubtitleFile(path, videoFileName);
|
||||||
if (File.Exists(subtitleFile))
|
if (File.Exists(subtitleFile))
|
||||||
{
|
{
|
||||||
@ -2187,7 +2187,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
return batchVideoAndSub;
|
return batchVideoAndSub;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dimension GetVideoDimension(string videoFileName)
|
private static Dimension GetVideoDimension(string videoFileName)
|
||||||
{
|
{
|
||||||
var mediaInfo = FfmpegMediaInfo.Parse(videoFileName);
|
var mediaInfo = FfmpegMediaInfo.Parse(videoFileName);
|
||||||
if (mediaInfo.Dimension.IsValid())
|
if (mediaInfo.Dimension.IsValid())
|
||||||
|
@ -973,12 +973,9 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
|||||||
if (!useCache)
|
if (!useCache)
|
||||||
{
|
{
|
||||||
var httpClient = new HttpClient();
|
var httpClient = new HttpClient();
|
||||||
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
|
|
||||||
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
|
|
||||||
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Ocp-Apim-Subscription-Key", nikseTextBoxApiKey.Text.Trim());
|
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Ocp-Apim-Subscription-Key", nikseTextBoxApiKey.Text.Trim());
|
||||||
|
|
||||||
var url = $"https://{nikseComboBoxRegion.Text.Trim()}.tts.speech.microsoft.com/cognitiveservices/voices/list";
|
var url = $"https://{nikseComboBoxRegion.Text.Trim()}.tts.speech.microsoft.com/cognitiveservices/voices/list";
|
||||||
var result = await httpClient.GetAsync(new Uri(url), CancellationToken.None);
|
var result = httpClient.GetAsync(new Uri(url)).Result;
|
||||||
var bytes = await result.Content.ReadAsByteArrayAsync();
|
var bytes = await result.Content.ReadAsByteArrayAsync();
|
||||||
|
|
||||||
if (!result.IsSuccessStatusCode)
|
if (!result.IsSuccessStatusCode)
|
||||||
@ -1858,14 +1855,14 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
|||||||
nikseComboBoxVoice.DropDownWidth = nikseComboBoxVoice.Width;
|
nikseComboBoxVoice.DropDownWidth = nikseComboBoxVoice.Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshVoices()
|
private bool RefreshVoices()
|
||||||
{
|
{
|
||||||
if (nikseTextBoxApiKey.Visible && string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
|
if (nikseTextBoxApiKey.Visible && string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
|
||||||
{
|
{
|
||||||
Cursor = Cursors.Default;
|
Cursor = Cursors.Default;
|
||||||
MessageBox.Show("Please add API key");
|
MessageBox.Show("Please add API key");
|
||||||
nikseTextBoxApiKey.Focus();
|
nikseTextBoxApiKey.Focus();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var engine = _engines.First(p => p.Index == nikseComboBoxEngine.SelectedIndex);
|
var engine = _engines.First(p => p.Index == nikseComboBoxEngine.SelectedIndex);
|
||||||
@ -1876,7 +1873,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
|||||||
Cursor = Cursors.Default;
|
Cursor = Cursors.Default;
|
||||||
MessageBox.Show("Please add region");
|
MessageBox.Show("Please add region");
|
||||||
nikseComboBoxRegion.Focus();
|
nikseComboBoxRegion.Focus();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = GetAzureVoices(false).Result;
|
var _ = GetAzureVoices(false).Result;
|
||||||
@ -1887,16 +1884,16 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
|||||||
GetElevenLabVoices(false);
|
GetElevenLabVoices(false);
|
||||||
nikseComboBoxEngine_SelectedIndexChanged(null, null);
|
nikseComboBoxEngine_SelectedIndexChanged(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void contextMenuStripVoices_Opening(object sender, System.ComponentModel.CancelEventArgs e)
|
private void contextMenuStripVoices_Opening(object sender, System.ComponentModel.CancelEventArgs e)
|
||||||
{
|
{
|
||||||
var engine = _engines.First(p => p.Index == nikseComboBoxEngine.SelectedIndex);
|
var engine = _engines.First(p => p.Index == nikseComboBoxEngine.SelectedIndex);
|
||||||
if (
|
if (engine.Id == TextToSpeechEngineId.AzureTextToSpeech ||
|
||||||
//engine.Id == TextToSpeechEngineId.AzureTextToSpeech ||
|
|
||||||
engine.Id == TextToSpeechEngineId.ElevenLabs ||
|
engine.Id == TextToSpeechEngineId.ElevenLabs ||
|
||||||
engine.Id == TextToSpeechEngineId.Piper
|
engine.Id == TextToSpeechEngineId.Piper)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1915,10 +1912,13 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Cursor = Cursors.WaitCursor;
|
Cursor = Cursors.WaitCursor;
|
||||||
RefreshVoices();
|
var ok = RefreshVoices();
|
||||||
Cursor = Cursors.Default;
|
Cursor = Cursors.Default;
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
MessageBox.Show(this, "Voice list downloaded");
|
MessageBox.Show(this, "Voice list downloaded");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Cursor = Cursors.Default;
|
Cursor = Cursors.Default;
|
||||||
|
Loading…
Reference in New Issue
Block a user