gpt4 book ai didi

java - "file does not contain class api.configuration"是什么意思?

转载 作者:行者123 更新时间:2023-11-30 05:35:25 25 4
gpt4 key购买 nike

请记住,我对 Java 完全陌生。我不知道“类”之类的东西是什么。

当尝试编译(javac -g Sphinx.java)此代码时:

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PrintWriter;

import api.Configuration;
import api.SpeechResult;
import api.LiveSpeechRecognizer;

public class Sphinx {
public static void main(String[] args) throws Exception {

Configuration configuration = new Configuration();

configuration.setAcousticModelPath("models/en-us/en-us");
configuration.setDictionaryPath("models/en-us/cmudict-en-us.dict");
configuration.setLanguageModelPath("models/en-us/en-us.lm.bin");

PrintWriter pw = new PrintWriter(new PrintWriter("status.txt"));
LiveSpeechRecognizer recognizer = new LiveSpeechRecognizer(configuration);
recognizer.startRecognition(true);
pw.print("running");
SpeechResult result = recognizer.getResult();
recognizer.stopRecognition();
pw.print("stopped");
pw.close();

PrintWriter pw2 = new PrintWriter(new PrintWriter("result.txt"));
pw2.println(result);
pw2.close();
}
}

我收到此错误:

Sphinx.java:8: error: cannot access Configuration
import api.Configuration;
^
bad source file: .\api\Configuration.java
file does not contain class api.Configuration
Please remove or make sure it appears in the correct subdirectory of the sourcepath.

我不太明白“文件不包含类 api.configuration”是什么意思,或者如何修复它。

最佳答案

查看您的错误消息,您的 ./api/Configuration.java 文件似乎缺少包声明。

您能否确保在 ./api/Configuration.java 中第一行有

package api;

这告诉编译器您的文件可以通过 api 包访问,而不是默认包。

关于java - "file does not contain class api.configuration"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56743633/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com