feat: Implement a modular skill system with hotword detection, streaming text output, and enhanced logging.
This commit is contained in:
@@ -22,4 +22,47 @@ public static class Notifications
|
||||
Console.WriteLine($"[Notifications] Failed to send notification: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void PlaySound(string soundPath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(soundPath)) return;
|
||||
try
|
||||
{
|
||||
var absolutePath = soundPath;
|
||||
if (!Path.IsPathRooted(absolutePath))
|
||||
absolutePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, absolutePath);
|
||||
|
||||
if (!File.Exists(absolutePath))
|
||||
{
|
||||
var resourceName = "Toak." + soundPath.Replace("/", ".").Replace("\\", ".");
|
||||
using var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
|
||||
if (stream != null)
|
||||
{
|
||||
absolutePath = Path.Combine(Path.GetTempPath(), "toak_" + Path.GetFileName(soundPath));
|
||||
if (!File.Exists(absolutePath))
|
||||
{
|
||||
using var fileStream = File.Create(absolutePath);
|
||||
stream.CopyTo(fileStream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var pInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "paplay",
|
||||
Arguments = $"\"{absolutePath}\"",
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true
|
||||
};
|
||||
Process.Start(pInfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[Notifications] Failed to play sound: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user