successfully posts to speech service
This commit is contained in:
parent
5b3315d812
commit
90f50b9e2b
45
Program.cs
45
Program.cs
@ -20,12 +20,14 @@ namespace placeholdervo
|
|||||||
private static partial Regex NonTextLine();
|
private static partial Regex NonTextLine();
|
||||||
public static Config conf;
|
public static Config conf;
|
||||||
private static string workingDir = "./";
|
private static string workingDir = "./";
|
||||||
|
private static HttpClient hc;
|
||||||
|
|
||||||
private static ConcurrentQueue<string> scriptFragmentFiles = new ConcurrentQueue<string>();
|
private static ConcurrentQueue<string> scriptFragmentFiles = new ConcurrentQueue<string>();
|
||||||
private static ConcurrentQueue<string> titleCardLines = new ConcurrentQueue<string>();
|
private static ConcurrentQueue<string> titleCardLines = new ConcurrentQueue<string>();
|
||||||
private static CancellationToken scriptFileCancellationToken;
|
private static CancellationToken scriptFileCancellationToken;
|
||||||
|
|
||||||
// private static async void webcall()
|
//from when I cut it up into separate files
|
||||||
|
// private static async void ApiCalls()
|
||||||
// {
|
// {
|
||||||
// var hc = new HttpClient(){ BaseAddress = new Uri(conf.speech_service)};
|
// var hc = new HttpClient(){ BaseAddress = new Uri(conf.speech_service)};
|
||||||
// while(true)
|
// while(true)
|
||||||
@ -121,6 +123,8 @@ namespace placeholdervo
|
|||||||
AppDomain.CurrentDomain.BaseDirectory + "appsettings.json"))
|
AppDomain.CurrentDomain.BaseDirectory + "appsettings.json"))
|
||||||
?? new Config();
|
?? new Config();
|
||||||
|
|
||||||
|
hc = new HttpClient(){ BaseAddress = new Uri(conf.speech_service)};
|
||||||
|
|
||||||
var scriptPath = args?.FirstOrDefault();
|
var scriptPath = args?.FirstOrDefault();
|
||||||
if(string.IsNullOrWhiteSpace(scriptPath))
|
if(string.IsNullOrWhiteSpace(scriptPath))
|
||||||
{
|
{
|
||||||
@ -173,6 +177,8 @@ namespace placeholdervo
|
|||||||
|
|
||||||
var scriptStripped = $"{scriptBasename}-primaryVO.txt";
|
var scriptStripped = $"{scriptBasename}-primaryVO.txt";
|
||||||
File.WriteAllLines(scriptStripped, primaryVOLines);
|
File.WriteAllLines(scriptStripped, primaryVOLines);
|
||||||
|
Task.WaitAny(PrimaryVO(scriptStripped));
|
||||||
|
|
||||||
var titleLevels = new List<int>(){0};
|
var titleLevels = new List<int>(){0};
|
||||||
var titleIncrementDepth = 0;
|
var titleIncrementDepth = 0;
|
||||||
foreach(var l in titlecardUnprocessed)
|
foreach(var l in titlecardUnprocessed)
|
||||||
@ -200,7 +206,7 @@ namespace placeholdervo
|
|||||||
}
|
}
|
||||||
Console.WriteLine($"title card: {TitleCardText}");
|
Console.WriteLine($"title card: {TitleCardText}");
|
||||||
titlecardLines.Add(TitleCardText);
|
titlecardLines.Add(TitleCardText);
|
||||||
//tc command
|
//TODO: tc command
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -240,7 +246,7 @@ namespace placeholdervo
|
|||||||
var parameterText = thisLine[(thisLine.IndexOf(']') + 1) ..].Trim();
|
var parameterText = thisLine[(thisLine.IndexOf(']') + 1) ..].Trim();
|
||||||
if(directiveName == "note")
|
if(directiveName == "note")
|
||||||
{
|
{
|
||||||
//note command
|
//TODO: note command
|
||||||
noteLines.Add(parameterText);
|
noteLines.Add(parameterText);
|
||||||
Console.WriteLine($"on screen note: {parameterText}");
|
Console.WriteLine($"on screen note: {parameterText}");
|
||||||
}
|
}
|
||||||
@ -251,13 +257,16 @@ namespace placeholdervo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//alt va command with altVOLines
|
if(altVOLines?.Count > 0)
|
||||||
File.WriteAllLines($"{scriptBasename}-altVO.txt", altVOLines);
|
{
|
||||||
|
//TODO: alt va command with altVOLines
|
||||||
|
File.WriteAllLines($"{scriptBasename}-altVO.txt", altVOLines);
|
||||||
|
}
|
||||||
|
|
||||||
// execute them all
|
// execute them all
|
||||||
Task.Run(OfflineStuff);
|
// Task.Run(OfflineStuff); //e.g., generate title cards and credits
|
||||||
Task.Run(ApiCalls);
|
// Task.Run(ApiCalls); //e.g. generate voice
|
||||||
Task.Run(FilePickups);
|
// await Task.Run(FilePickups);
|
||||||
|
|
||||||
// cancelSource.Cancel();
|
// cancelSource.Cancel();
|
||||||
// Console.WriteLine("http client \"cancelled\".");
|
// Console.WriteLine("http client \"cancelled\".");
|
||||||
@ -275,5 +284,25 @@ namespace placeholdervo
|
|||||||
// }
|
// }
|
||||||
// Console.WriteLine($"fileRetrieveThread done ({fileRetrieveThread.ThreadState}). kbai");
|
// Console.WriteLine($"fileRetrieveThread done ({fileRetrieveThread.ThreadState}). kbai");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async Task PrimaryVO(string scriptStripped)
|
||||||
|
{
|
||||||
|
HttpContent fileStreamContent = new StreamContent(File.OpenRead(scriptStripped));
|
||||||
|
using (var formData = new MultipartFormDataContent())
|
||||||
|
{
|
||||||
|
formData.Add(fileStreamContent, "file1", "file1");
|
||||||
|
|
||||||
|
var response = await hc.PostAsync("/speak", formData);
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"{response.StatusCode} - {response.ReasonPhrase} - {await response.Content.ReadAsStringAsync()}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"success; {await response.Content.ReadAsStringAsync()}.");
|
||||||
|
//TODO: add to queue to watch for?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user