从Flex4 Adob​​e AIR应用程序运行Festival TTS的建议

时间:2010-11-18 10:33:51

标签: flex air flex4 mxml festival

我正在尝试从AIR 2应用运行Festival text to speech

以下是启动记事本的示例代码

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" width="1024" height="768">

    <fx:Script>
        <![CDATA[
            protected function button1_clickHandler(event:MouseEvent):void
            {
                var exe:File = new File("c:/Windows/notepad.exe");
                var nativeProcess:NativeProcess = new NativeProcess();
                var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
                nativeProcessStartupInfo.executable = exe;
                var args:Vector.<String> = new Vector.<String>(); 
                args.push("e:/temp/Hello.txt");
                nativeProcessStartupInfo.arguments = args;
                nativeProcess.start(nativeProcessStartupInfo);
            }
        ]]>
    </fx:Script>

    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Button x="265" y="236" label="Hello Button" width="465" height="131" fontSize="30" click="button1_clickHandler(event)"/>
</s:WindowedApplication>

我想在按钮点击上运行的命令在这里:

c:\FestivalTTS>echo "Hello world" | festival --tts

或像这样开始音乐节:

c:\FestivalTTS>festival.exe --pipe

然后在Festival命令提示符中键入以下内容

(SayText "Hello world.")

1 个答案:

答案 0 :(得分:0)

阅读文档,他们统治。您可以使用NativeProcess'standardInput和standardOutput与流程进行通信。请参阅sample