我很难弄清楚如何在intellij中实际使用导入的模块。
我正在尝试使用maryTTS。更确切地说,是MaryInterface。https://github.com/marytts/marytts/wiki/MaryInterface
自述文件建议使用maven或gradle。我从未使用过maven,这并不意味着我不能使用maven,但我当前的项目不是maven项目。这只是一个普通的java项目。gradle也是如此。我会试试maven。
我开始了一个简单的新项目,叫做test。
然后我通过以下方式导入模块:
File->New->Module from existing sources.这给我留下了一个我不知道/不知道如何访问的模块。所以基本上在我的项目中有两个独立的模块。
这意味着如果我使用下面的测试代码:
import javax.sound.sampled.AudioInputStream;
import marytts.LocalMaryInterface;
import marytts.MaryInterface;
import marytts.exceptions.MaryConfigurationException;
import marytts.exceptions.SynthesisException;
import marytts.util.data.audio.AudioPlayer;
public class Voice
{
private MaryInterface marytts;
private AudioPlayer ap;
public Voice(String voiceName)
{
try
{
marytts = new LocalMaryInterface();
marytts.setVoice(voiceName);
ap = new AudioPlayer();
}
catch (MaryConfigurationException ex)
{
ex.printStackTrace();
}
}
public void say(String input)
{
try
{
AudioInputStream audio = marytts.generateAudio(input);
ap.setAudio(audio);
ap.start();
}
catch (SynthesisException ex)
{
System.err.println("Error saying phrase.");
}
}
}从我的主模块导入的所有marytts都失败。显然,它们在marytts模块中很好用。
我还尝试创建一个空白的maven项目,然后将示例代码添加到pom.xml中。我把artifactId改成了marytts。然后,它只是在~/.m2中存在的文件的依赖项下给出了一个路径错误。
这里有个例子。https://github.com/marytts/marytts
<repositories>
<repository>
<id>central</id>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>de.dfki.mary</groupId>
<artifactId>marytts</artifactId>
<version>5.2</version>
</dependency>
</dependencies>我已经看过智者的文件了。模块导入看起来非常简单。显然,我没有参与到这个过程中,也没有做错什么。
所以我的问题是,要从我的主模块调用该接口,正确的步骤是什么?我应该使用/学习maven吗?
发布于 2016-08-14 23:13:04
我不确定为什么这是答案,但它似乎是有效的。
我使用的是自述文件中的原文,但必须添加一个id。
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>de.dfki.mary</groupId>
<artifactId>voice-cmu-slt-hsmm</artifactId>
<version>5.2</version>
</dependency>
</dependencies>这似乎在我能使用所有导入语句并创建MaryInterface的情况下都能起作用。
我不明白的是,为什么它不会这样工作。我只是假设我需要marytts的神器。
http://cs.unk.edu/~mcconvilletl/?p=59
https://stackoverflow.com/questions/38937437
复制相似问题