| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- namespace Speech.tts {
- class VoiceRSS {
- public Process GenerateTTS(string path, string voiceName, string lang, string sentance) {
- Process p = new Process();
- string key = "1234567890";
- p.StartInfo.FileName = "java org.openhab.voice.voicerss.tool.CreateTTSCache --api-key "+key+" "+path+" "+lang+" \""+sentance+"\"";
- p.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
- p.StartInfo.CreateNoWindow = true;
- return p;
- }
- public string GetName() {
- return "Voice RSS";
- }
- public string generateFileName() {
- Random rnd = new Random();
- return this.DateTimeToCrypt() + "_" + rnd.Next(0, 999999).ToString().PadLeft(6, '0') + ".tmp";
- }
- public string generateFileName(string file_extention) {
- string cr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- Random rnd = new Random();
- return this.DateTimeToCrypt() + "_" + cr.Substring(rnd.Next(0, cr.Length - 1)) + cr.Substring(rnd.Next(0, cr.Length - 1)) + cr.Substring(rnd.Next(0, cr.Length - 1)) + cr.Substring(rnd.Next(0, cr.Length - 1)) + rnd.Next(0, 999999).ToString().PadLeft(6, '0') + "." + file_extention;
- }
- protected string DateTimeToCrypt() {
- return this.DateTimeToCrypt(DateTime.Now);
- }
- protected string DateTimeToCrypt(DateTime dt) {
- string cr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- int y = dt.Year;
- int M = dt.Month;
- int d = dt.Day;
- int h = dt.Hour;
- int i = dt.Minute;
- int s = dt.Second;
- int f = dt.Millisecond;
- int y1 = (int)Math.Floor((decimal)(y / cr.Length));
- int y2 = y - (y1 * cr.Length);
- int sum1 = (M * d) % (cr.Length - 1);
- int sum2 = (h * i * s) % (cr.Length - 1);
- return cr.Substring(y1, 1) + cr.Substring(y2, 1) +
- cr.Substring(M, 1) +
- cr.Substring(d, 1) +
- cr.Substring(h, 1) +
- cr.Substring(i, 1) +
- cr.Substring(s, 1) +
- cr.Substring(f % (cr.Length - 1), 1) +
- cr.Substring(sum1, 1) +
- cr.Substring(sum2, 1)
- ;
- }
- }
- }
|