我无法弄清楚如何在intellij中真正使用导入的模块。在intellij中使用导入的模块
我正在尝试使用maryTTS。更确切地说MaryInterface。 https://github.com/marytts/marytts/wiki/MaryInterface
自述文件说使用maven或gradle。我从来没有使用过maven,但这并不意味着我不能,但我目前的项目不是maven项目。只是一个普通的Java项目。和gradle一样。我会尝试maven。
我刚开始一个简单的新项目叫做测试。
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>
我已经浏览过intellj的文档。模块导入看起来非常简单。显然,我没有参与这个过程或者做错了什么。
所以我的问题是什么是能够从我的主要模块调用该接口的正确步骤?我应该使用/学习maven吗?