简体   繁体   English

如何在Java中使用Sphinx和Freetts管理hello.gram进行对话

[英]how to manage hello.gram for conversation using sphinx and freetts in java

I am developing small voice based interaction tool using sphinx (Speech to Text) and FreeTTS(Text to Speech) in java. 我正在使用Java中的狮身人面像(语音到文本)和FreeTTS(文本到语音)开发基于语音的小型交互工具。

for eg : FreeTTS gives voice command like Name : user will reply his name and age and place.everything is static. 例如:FreeTTS发出语音命令,如“名称”:用户将回复其姓名,年龄和地点。一切都是静态的。

How to write hello.gram in sphinx to achieve this 如何在狮身人面像中编写hello.gram以实现此目的

public<greet>=[<name>] [<age>] [<place>];
<name> = john | max;
<age> = ten | nine ;
<place> = France | Spain;

Voice command : What is your name my reply : Max 语音命令:你叫什么名字我的回复:最大

Observation : Max ten 观察:最多十个

Voice command : what is your age my reply : nine 语音命令:您几岁了?我的回复:九

Observation : nine France 观察:九法

I want only names should be observed when i say name.its highly intermittent too :( 我只想在说name.name的时候就应该注意名字。

Thanks in advance. 提前致谢。

modified based on Alexander's answer. 根据亚历山大的答案进行了修改。

There is no magical method to do what you want. 没有神奇的方法可以做您想要的。 You have to specify all phrases that you want to be recognized in your grammar. 您必须指定要在语法中识别的所有短语。 The only thing I can recommend is to factorize some rules, eg numbers: 我唯一推荐的是分解一些规则,例如数字:

<digits> = one | <数字> = 1 | two | 二| three | 三| four ; 四;
<decades> = twenty | <十年> =二十| thirty | 三十| forty ; 四十;
<numto44> = <decades> | <numto44> = <十年> | <decades> <digits> ; <decades> <digits>;

You can use below code to avoid it . 您可以使用下面的代码来避免它。

public <name> = john | max;
public <age> = ten | nine ;
public <place> = France | Spain;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM