0

当我启动 javafx 窗口和 sphinx 应用程序时,我遇到了一些错误,如果我先运行 sphinx 然后启动窗口,程序不会记录任何命令,只有当我关闭窗口时,如果我先启动窗口 sphinx像往常一样记录,但会挡住窗口。

我的窗口:

public class Escolha extends Application{
private static final Image FOTOPROXY = new Image(Escolha.class.getResourceAsStream("/foto/proxy.png"));
private static final Font Corleone = Font.loadFont(Escolha.class.getResourceAsStream("/fontes/corleone.ttf"), 20);

public static void main(String[] args) {
    launch(args);

}

@Override
public void start(Stage primaryStage) throws Exception {

    init(primaryStage);
    primaryStage.show();

}

public void init(final Stage primaryStage) {
    //primaryStage.setScene(new Scene(addBorda()));
    Group root = new Group();
    primaryStage.setScene(new Scene(root));


    HBox hboxImagem = new HBox();
    hboxImagem.setPadding(new Insets(5, 5, 5, 25));
    hboxImagem.setSpacing(10);
    hboxImagem.setStyle("-fx-background-color: #b3ccff");

    ImageView imagem = new ImageView(FOTOPROXY);        
    imagem.setFitHeight(200);
    imagem.setFitWidth(550);

    hboxImagem.getChildren().add(imagem);

    HBox hboxTexto = new HBox();

    hboxTexto.setPadding(new Insets(15, 5, 15, 15));
    hboxTexto.setSpacing(10);
    hboxTexto.setTranslateY(210);
    hboxTexto.setStyle("-fx-border-style: solid;" + "-fx-border-width: 4;" + 
            "-fx-border-color: #99b3ff");

    HBox hboxBotoes = new HBox();
    hboxBotoes.setPadding(new Insets(35, 1, 1, -20));
    hboxBotoes.setSpacing(10);

    Text texto = new Text("Caso possua proxy é necessário configura-lo antes de executar a Olivia,\n" +
            "você deseja configurar agora?");       
    texto.setFont(Corleone);    


    EventHandler<ActionEvent> vaiSim = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {       
            Configuracao.configurarProxy();

        }

    };

    Button sim = new Button("Sim");
    sim.setStyle("-fx-base: #b3ccff");  
    sim.setOnAction(vaiSim);


    EventHandler<ActionEvent> vaiNao = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {

            HelloWorld.RecDeVoz();


        }

    };

    Button nao = new Button("Não");
    nao.setStyle("-fx-base: #b3ccff");
    nao.setOnAction(vaiNao);


    hboxBotoes.getChildren().addAll(sim, nao);

    hboxTexto.getChildren().addAll(texto, hboxBotoes);

    root.getChildren().addAll(hboxImagem, hboxTexto);




}
4

1 回答 1

0

对您的麦克风的访问仅限于单个应用程序。Yuor javafx 也在访问麦克风,正如该行所暗示的那样HelloWorld.RecDeVoz();

如果你想在你的应用程序中使用 Sphinx4,你很可能必须集成它:构建,将 sphinx jar 链接到应用程序,然后开始识别。

如果您尝试离线识别(从录制的音频文件),您应该更改 sphinx 配置以使用文件源而不是麦克风作为输入。

于 2013-06-26T14:34:56.857 回答