Example #1
0
 public UniSynthChannel(UniSynthSession sess, UniSynthTermination term, Semaphore sem, string text) :
     base(sess, term)
 {
     this.term = term;
     this.sem  = sem;
     this.text = text;
 }
Example #2
0
    static void Main(string[] argv)
    {
        if (argv.Length < 1)
        {
            Console.WriteLine("Usage:");
            Console.WriteLine("\tUniSynth \"This is a synthetic voice.\"");
            Environment.Exit(1);
        }
        // Just detect various directory layout constellations
        if (!Directory.Exists(ROOT_DIR))
        {
            ROOT_DIR = "../../../../UniMRCP";
        }
        if (!Directory.Exists(ROOT_DIR))
        {
            ROOT_DIR = "../../../../unimrcp";
        }
        string text    = String.Join(" ", argv).Trim();
        string outfile = String.Format("{0}/data/{1}", ROOT_DIR, PCM_OUT_FILE);

        ushort major, minor, patch;

        UniMRCPClient.WrapperVersion(out major, out minor, out patch);
        Console.WriteLine("This is a sample C# UniMRCP client synthesizer scenario.");
        Console.WriteLine("Wrapper version: {0}.{1}.{2}", major, minor, patch);
        Console.WriteLine("Use client configuration from {0}/conf/unimrcpclient.xml", ROOT_DIR);
        Console.WriteLine("Use profile {0}", MRCP_PROFILE);
        Console.WriteLine("Synthesize text: `{0}'", text);
        Console.WriteLine("Write output to file: {0}", outfile);
        Console.WriteLine();
        Console.WriteLine("Press enter to start the session...");
        Console.ReadKey();

        UniSynthLogger logger = new UniSynthLogger();

        try
        {
            // Initialize platform first
            UniMRCPClient.StaticInitialize(logger, UniMRCPLogPriority.INFO);
        }
        catch (ApplicationException ex)
        {
            Console.WriteLine("Unable to initialize platform: " + ex.Message);
            Environment.Exit(1);
        }

        UniMRCPClient   client = null;
        UniSynthSession sess   = null;
        UniSynthChannel chan   = null;

        try
        {
            // Create and start client in a root dir
            client = new UniMRCPClient(ROOT_DIR, true);
            // Create a session using MRCP profile MRCP_PROFILE
            sess = new UniSynthSession(client, MRCP_PROFILE);
            // Create audio termination with capabilities
            UniSynthTermination term = new UniSynthTermination(sess, outfile);
            term.AddCapability("LPCM", UniMRCPSampleRate.SAMPLE_RATE_8000);
            // Semaphore to wait for completion
            Semaphore sem = new Semaphore(0, 1);
            // Add signaling channel (and start processing in OnAdd method
            chan = new UniSynthChannel(sess, term, sem, text);

            // Now wait until the processing finishes
            sem.WaitOne();
        }
        catch (ApplicationException ex)
        {
            err = 1;
            Console.WriteLine("An error occured: " + ex.Message);
        }

        // Ensure correct destruction order (do not let GC decide)
        if (chan != null)
        {
            chan.Dispose();
        }
        if (sess != null)
        {
            sess.Dispose();
        }
        if (client != null)
        {
            client.Dispose();
        }

        UniMRCPClient.StaticDeinitialize();
        Console.WriteLine("Program finished, memory released. Press enter to exit.");
        Console.ReadKey();
        Environment.Exit(err);
    }
Example #3
0
    static void Main(string[] argv)
    {
        if (argv.Length < 1)
        {
            Console.WriteLine("Usage:");
            Console.WriteLine("\tUniSynth \"This is a synthetic voice.\"");
            Environment.Exit(1);
        }
        // Just detect various directory layout constellations
        if (!Directory.Exists(ROOT_DIR))
            ROOT_DIR = "../../../../UniMRCP";
        if (!Directory.Exists(ROOT_DIR))
            ROOT_DIR = "../../../../unimrcp";
        string text = String.Join(" ", argv).Trim();
        string outfile = String.Format("{0}/data/{1}", ROOT_DIR, PCM_OUT_FILE);

        ushort major, minor, patch;
        UniMRCPClient.WrapperVersion(out major, out minor, out patch);
        Console.WriteLine("This is a sample C# UniMRCP client synthesizer scenario.");
        Console.WriteLine("Wrapper version: {0}.{1}.{2}", major, minor, patch);
        Console.WriteLine("Use client configuration from {0}/conf/unimrcpclient.xml", ROOT_DIR);
        Console.WriteLine("Use profile {0}", MRCP_PROFILE);
        Console.WriteLine("Synthesize text: `{0}'", text);
        Console.WriteLine("Write output to file: {0}", outfile);
        Console.WriteLine();
        Console.WriteLine("Press enter to start the session...");
        Console.ReadKey();

        UniSynthLogger logger = new UniSynthLogger();
        try
        {
            // Initialize platform first
            UniMRCPClient.StaticInitialize(logger, UniMRCPLogPriority.INFO);
        }
        catch (ApplicationException ex)
        {
            Console.WriteLine("Unable to initialize platform: " + ex.Message);
            Environment.Exit(1);
        }

        UniMRCPClient client = null;
        UniSynthSession sess = null;
        UniSynthChannel chan = null;
        try
        {
            // Create and start client in a root dir
            client = new UniMRCPClient(ROOT_DIR, true);
            // Create a session using MRCP profile MRCP_PROFILE
            sess = new UniSynthSession(client, MRCP_PROFILE);
            // Create audio termination with capabilities
            UniSynthTermination term = new UniSynthTermination(sess, outfile);
            term.AddCapability("LPCM", UniMRCPSampleRate.SAMPLE_RATE_8000);
            // Semaphore to wait for completion
            Semaphore sem = new Semaphore(0, 1);
            // Add signaling channel (and start processing in OnAdd method
            chan = new UniSynthChannel(sess, term, sem, text);

            // Now wait until the processing finishes
            sem.WaitOne();
        }
        catch (ApplicationException ex)
        {
            err = 1;
            Console.WriteLine("An error occured: " + ex.Message);
        }

        // Ensure correct destruction order (do not let GC decide)
        if (chan != null) chan.Dispose();
        if (sess != null) sess.Dispose();
        if (client != null) client.Dispose();

        UniMRCPClient.StaticDeinitialize();
        Console.WriteLine("Program finished, memory released. Press enter to exit.");
        Console.ReadKey();
        Environment.Exit(err);
    }
Example #4
0
 public UniSynthChannel(UniSynthSession sess, UniSynthTermination term, Semaphore sem, string text)
     : base(sess, term)
 {
     this.term = term;
     this.sem = sem;
     this.text = text;
 }