firefox stuff
theoretically, we're done? o_O
This commit is contained in:
parent
b49516451f
commit
f3a134ad92
@ -4,4 +4,9 @@ public class Config
|
|||||||
{
|
{
|
||||||
public string speech_service { get; set; } = "http://eligos.lan:5400";
|
public string speech_service { get; set; } = "http://eligos.lan:5400";
|
||||||
public string sync_dropoff { get; set; } = "/home/adam/Sync/eligos documents/";
|
public string sync_dropoff { get; set; } = "/home/adam/Sync/eligos documents/";
|
||||||
|
public string VODropoff {get;set; } = "./Sounds/VO";
|
||||||
|
public string titlecard_command {get;set; } = "echo";
|
||||||
|
public string titlecards_dest {get; set; } = "./notes";
|
||||||
|
public string note_command {get;set; } = "echo";
|
||||||
|
public string notes_dest {get; set; } = "./notes";
|
||||||
}
|
}
|
||||||
|
113
Program.cs
113
Program.cs
@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection.Metadata.Ecma335;
|
using System.Reflection.Metadata.Ecma335;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices.Marshalling;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
@ -22,56 +23,11 @@ namespace placeholdervo
|
|||||||
private static string workingDir = "./";
|
private static string workingDir = "./";
|
||||||
private static HttpClient hc;
|
private static HttpClient hc;
|
||||||
|
|
||||||
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 ConcurrentQueue<string> noteLines = new ConcurrentQueue<string>();
|
||||||
private static ConcurrentDictionary<string, string> filePickups = new ConcurrentDictionary<string, string>();
|
private static ConcurrentDictionary<string, string> filePickups = new ConcurrentDictionary<string, string>();
|
||||||
private static CancellationToken scriptFileCancellationToken;
|
private static CancellationToken scriptFileCancellationToken;
|
||||||
|
|
||||||
//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)
|
|
||||||
// {
|
|
||||||
// while(!scriptFragmentFiles.IsEmpty)
|
|
||||||
// {
|
|
||||||
// string scriptFragment;
|
|
||||||
// scriptFragmentFiles.TryDequeue(out scriptFragment);
|
|
||||||
// if(scriptFragment == null) continue;
|
|
||||||
// Console.WriteLine(scriptFragment);
|
|
||||||
|
|
||||||
// HttpContent fileStreamContent = new StreamContent(File.OpenRead(scriptFragment));
|
|
||||||
// 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
|
|
||||||
// {
|
|
||||||
// var resp = string.Join(", ", JsonConvert.DeserializeObject<string[]>(await response.Content.ReadAsStringAsync()));
|
|
||||||
// Console.WriteLine($"success; {resp}.");
|
|
||||||
// if(resp != null)
|
|
||||||
// {
|
|
||||||
// scriptFragmentVoiceFiles[resp] = scriptFragment;
|
|
||||||
// Console.WriteLine("Ditching script fragment file.");
|
|
||||||
// File.Delete(scriptFragment);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if(scriptFileCancellationToken.IsCancellationRequested && scriptFragmentFiles.IsEmpty)
|
|
||||||
// {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
///<summary>mostly just to give myself the reminder about paths</summary>
|
///<summary>mostly just to give myself the reminder about paths</summary>
|
||||||
///<param name="src">the *complete path* of the awaited file. you might want conf.sync_dropoff</param>
|
///<param name="src">the *complete path* of the awaited file. you might want conf.sync_dropoff</param>
|
||||||
///<param name="dest">the *complete path* to move the file to.</param>
|
///<param name="dest">the *complete path* to move the file to.</param>
|
||||||
@ -115,6 +71,22 @@ namespace placeholdervo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async void FFStuff()
|
||||||
|
{
|
||||||
|
var cardCount = 0;
|
||||||
|
foreach(var tcL in titleCardLines)
|
||||||
|
{
|
||||||
|
await Process.Start(conf.titlecard_command, tcL).WaitForExitAsync();
|
||||||
|
File.Move("tc.png", Path.Combine(conf.titlecards_dest, $"tc{cardCount++}.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
cardCount = 0;
|
||||||
|
foreach(var nL in noteLines)
|
||||||
|
{
|
||||||
|
await Process.Start(conf.titlecard_command, nL).WaitForExitAsync();
|
||||||
|
File.Move("n0.png", Path.Combine(conf.notes_dest, $"note{cardCount++}.png"));
|
||||||
|
}
|
||||||
|
}
|
||||||
public static async Task Main(string[] args)
|
public static async Task Main(string[] args)
|
||||||
{
|
{
|
||||||
conf = JsonConvert.DeserializeObject<Config>(
|
conf = JsonConvert.DeserializeObject<Config>(
|
||||||
@ -123,6 +95,7 @@ namespace placeholdervo
|
|||||||
?? new Config();
|
?? new Config();
|
||||||
|
|
||||||
hc = new HttpClient(){ BaseAddress = new Uri(conf.speech_service)};
|
hc = new HttpClient(){ BaseAddress = new Uri(conf.speech_service)};
|
||||||
|
var taskHeap = new List<Task>();
|
||||||
|
|
||||||
var scriptPath = args?.FirstOrDefault();
|
var scriptPath = args?.FirstOrDefault();
|
||||||
if(string.IsNullOrWhiteSpace(scriptPath))
|
if(string.IsNullOrWhiteSpace(scriptPath))
|
||||||
@ -143,10 +116,6 @@ namespace placeholdervo
|
|||||||
|
|
||||||
var cancelSource = new CancellationTokenSource();
|
var cancelSource = new CancellationTokenSource();
|
||||||
scriptFileCancellationToken = cancelSource.Token;
|
scriptFileCancellationToken = cancelSource.Token;
|
||||||
// var apiCallThread = new Thread(new ThreadStart(webcall));
|
|
||||||
// apiCallThread.Start();
|
|
||||||
// var fileRetrieveThread = new Thread(new ThreadStart(filePickup));
|
|
||||||
// fileRetrieveThread.Start();
|
|
||||||
|
|
||||||
var lines = File.ReadAllLines(scriptPath)
|
var lines = File.ReadAllLines(scriptPath)
|
||||||
.Append("\n").Append("\n");
|
.Append("\n").Append("\n");
|
||||||
@ -176,7 +145,7 @@ namespace placeholdervo
|
|||||||
|
|
||||||
var scriptStripped = $"{scriptBasename}-primaryVO.txt";
|
var scriptStripped = $"{scriptBasename}-primaryVO.txt";
|
||||||
File.WriteAllLines(scriptStripped, primaryVOLines);
|
File.WriteAllLines(scriptStripped, primaryVOLines);
|
||||||
Task.WaitAny(PrimaryVO(scriptStripped));
|
taskHeap.Add(ttsVO(scriptStripped, Path.Combine(conf.VODropoff, $"primaryVO")));
|
||||||
|
|
||||||
var titleLevels = new List<int>(){0};
|
var titleLevels = new List<int>(){0};
|
||||||
var titleIncrementDepth = 0;
|
var titleIncrementDepth = 0;
|
||||||
@ -205,7 +174,6 @@ namespace placeholdervo
|
|||||||
}
|
}
|
||||||
Console.WriteLine($"title card: {TitleCardText}");
|
Console.WriteLine($"title card: {TitleCardText}");
|
||||||
titlecardLines.Add(TitleCardText);
|
titlecardLines.Add(TitleCardText);
|
||||||
//TODO: tc command
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -245,7 +213,6 @@ namespace placeholdervo
|
|||||||
var parameterText = thisLine[(thisLine.IndexOf(']') + 1) ..].Trim();
|
var parameterText = thisLine[(thisLine.IndexOf(']') + 1) ..].Trim();
|
||||||
if(directiveName == "note")
|
if(directiveName == "note")
|
||||||
{
|
{
|
||||||
//TODO: note command
|
|
||||||
noteLines.Add(parameterText);
|
noteLines.Add(parameterText);
|
||||||
Console.WriteLine($"on screen note: {parameterText}");
|
Console.WriteLine($"on screen note: {parameterText}");
|
||||||
}
|
}
|
||||||
@ -258,35 +225,22 @@ namespace placeholdervo
|
|||||||
}
|
}
|
||||||
if(altVOLines?.Count > 0)
|
if(altVOLines?.Count > 0)
|
||||||
{
|
{
|
||||||
//TODO: alt va command with altVOLines
|
var altVOscript = $"{scriptBasename}-altVO.txt";
|
||||||
File.WriteAllLines($"{scriptBasename}-altVO.txt", altVOLines);
|
File.WriteAllLines(altVOscript, altVOLines);
|
||||||
|
taskHeap.Add(ttsVO(altVOscript, Path.Combine(conf.VODropoff, $"altVO")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// execute them all
|
// execute them all
|
||||||
//Task.Run(OfflineStuff);
|
taskHeap.Add(Task.Run(FFStuff));
|
||||||
//Task.Run(ApiCalls);
|
taskHeap.Add(Task.Run(filePickup));
|
||||||
var fpTask = Task.Run(filePickup);
|
cancelSource.Cancel();
|
||||||
|
Task.WaitAll([.. taskHeap]);
|
||||||
// cancelSource.Cancel();
|
Console.WriteLine("kbai");
|
||||||
// Console.WriteLine("http client \"cancelled\".");
|
|
||||||
// while(apiCallThread.ThreadState != System.Threading.ThreadState.Stopped)
|
|
||||||
// {
|
|
||||||
// Console.WriteLine("thread still running. waiting.");
|
|
||||||
// System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5));
|
|
||||||
// }
|
|
||||||
// Console.WriteLine($"api call thread done ({apiCallThread.ThreadState}).");
|
|
||||||
|
|
||||||
// while(fileRetrieveThread.ThreadState != System.Threading.ThreadState.Stopped)
|
|
||||||
// {
|
|
||||||
// Console.WriteLine("fileRetrieveThread still running. waiting.");
|
|
||||||
// System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5));
|
|
||||||
// }
|
|
||||||
// Console.WriteLine($"fileRetrieveThread done ({fileRetrieveThread.ThreadState}). kbai");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task PrimaryVO(string scriptStripped)
|
private static async Task ttsVO(string scriptPath, string destPath)
|
||||||
{
|
{
|
||||||
HttpContent fileStreamContent = new StreamContent(File.OpenRead(scriptStripped));
|
HttpContent fileStreamContent = new StreamContent(File.OpenRead(scriptPath));
|
||||||
using (var formData = new MultipartFormDataContent())
|
using (var formData = new MultipartFormDataContent())
|
||||||
{
|
{
|
||||||
formData.Add(fileStreamContent, "file1", "file1");
|
formData.Add(fileStreamContent, "file1", "file1");
|
||||||
@ -298,8 +252,11 @@ namespace placeholdervo
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($"success; {await response.Content.ReadAsStringAsync()}.");
|
var fname = await response.Content.ReadAsStringAsync();
|
||||||
//TODO: add to queue to watch for?
|
Console.WriteLine($"success; {fname}."); //"success" might be a strong word; it's successfully submitted. Its decided what filename it will, eventually, give it.
|
||||||
|
var ext = Path.GetExtension(fname);
|
||||||
|
Directory.CreateDirectory(conf.VODropoff);
|
||||||
|
awaitFile(Path.Combine(conf.sync_dropoff, fname), destPath + $".{ext}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user