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();
|
||||
public static Config conf;
|
||||
private static string workingDir = "./";
|
||||
private static HttpClient hc;
|
||||
|
||||
private static ConcurrentQueue<string> scriptFragmentFiles = new ConcurrentQueue<string>();
|
||||
private static ConcurrentQueue<string> titleCardLines = new ConcurrentQueue<string>();
|
||||
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)};
|
||||
// while(true)
|
||||
@ -121,6 +123,8 @@ namespace placeholdervo
|
||||
AppDomain.CurrentDomain.BaseDirectory + "appsettings.json"))
|
||||
?? new Config();
|
||||
|
||||
hc = new HttpClient(){ BaseAddress = new Uri(conf.speech_service)};
|
||||
|
||||
var scriptPath = args?.FirstOrDefault();
|
||||
if(string.IsNullOrWhiteSpace(scriptPath))
|
||||
{
|
||||
@ -173,6 +177,8 @@ namespace placeholdervo
|
||||
|
||||
var scriptStripped = $"{scriptBasename}-primaryVO.txt";
|
||||
File.WriteAllLines(scriptStripped, primaryVOLines);
|
||||
Task.WaitAny(PrimaryVO(scriptStripped));
|
||||
|
||||
var titleLevels = new List<int>(){0};
|
||||
var titleIncrementDepth = 0;
|
||||
foreach(var l in titlecardUnprocessed)
|
||||
@ -200,7 +206,7 @@ namespace placeholdervo
|
||||
}
|
||||
Console.WriteLine($"title card: {TitleCardText}");
|
||||
titlecardLines.Add(TitleCardText);
|
||||
//tc command
|
||||
//TODO: tc command
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -240,7 +246,7 @@ namespace placeholdervo
|
||||
var parameterText = thisLine[(thisLine.IndexOf(']') + 1) ..].Trim();
|
||||
if(directiveName == "note")
|
||||
{
|
||||
//note command
|
||||
//TODO: note command
|
||||
noteLines.Add(parameterText);
|
||||
Console.WriteLine($"on screen note: {parameterText}");
|
||||
}
|
||||
@ -251,13 +257,16 @@ namespace placeholdervo
|
||||
}
|
||||
}
|
||||
}
|
||||
//alt va command with altVOLines
|
||||
File.WriteAllLines($"{scriptBasename}-altVO.txt", altVOLines);
|
||||
if(altVOLines?.Count > 0)
|
||||
{
|
||||
//TODO: alt va command with altVOLines
|
||||
File.WriteAllLines($"{scriptBasename}-altVO.txt", altVOLines);
|
||||
}
|
||||
|
||||
// execute them all
|
||||
Task.Run(OfflineStuff);
|
||||
Task.Run(ApiCalls);
|
||||
Task.Run(FilePickups);
|
||||
// Task.Run(OfflineStuff); //e.g., generate title cards and credits
|
||||
// Task.Run(ApiCalls); //e.g. generate voice
|
||||
// await Task.Run(FilePickups);
|
||||
|
||||
// cancelSource.Cancel();
|
||||
// Console.WriteLine("http client \"cancelled\".");
|
||||
@ -275,5 +284,25 @@ namespace placeholdervo
|
||||
// }
|
||||
// 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