增加语音对话功能
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { joinPath } from "../platform/paths";
|
||||
|
||||
function profileDir(): string {
|
||||
const profile =
|
||||
(Zotero as any).Profile?.dir ||
|
||||
(Zotero as any).getProfileDirectory?.()?.path;
|
||||
if (!profile) {
|
||||
throw new Error("Cannot resolve Zotero profile directory");
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
/** `{Profile}/chatpapers/lecture/` — voice lecture data root */
|
||||
export function lectureDataRoot(): string {
|
||||
return joinPath(profileDir(), "chatpapers", "lecture");
|
||||
}
|
||||
|
||||
export function lectureDbPath(): string {
|
||||
return joinPath(lectureDataRoot(), "lecture.db");
|
||||
}
|
||||
|
||||
/** Interim JSON index until SQLite POC lands */
|
||||
export function lectureIndexPath(): string {
|
||||
return joinPath(lectureDataRoot(), "cache-index.json");
|
||||
}
|
||||
|
||||
export function audioRootDir(): string {
|
||||
return joinPath(lectureDataRoot(), "audio");
|
||||
}
|
||||
|
||||
export function audioDirForPaper(cacheKey: string): string {
|
||||
return joinPath(audioRootDir(), cacheKey);
|
||||
}
|
||||
|
||||
export function audioFilePath(
|
||||
cacheKey: string,
|
||||
unitId: string,
|
||||
ext: "wav" | "mp3" = "wav",
|
||||
): string {
|
||||
return joinPath(audioDirForPaper(cacheKey), `${unitId}.${ext}`);
|
||||
}
|
||||
|
||||
export function lectureSamplePath(name: string): string {
|
||||
return joinPath(lectureDataRoot(), "samples", name);
|
||||
}
|
||||
|
||||
export async function ensureSampleDir(): Promise<string> {
|
||||
const dir = joinPath(lectureDataRoot(), "samples");
|
||||
await IOUtils.makeDirectory(dir, {
|
||||
createAncestors: true,
|
||||
ignoreExisting: true,
|
||||
});
|
||||
return dir;
|
||||
}
|
||||
|
||||
export async function ensureLectureDirs(): Promise<void> {
|
||||
const root = lectureDataRoot();
|
||||
await IOUtils.makeDirectory(root, {
|
||||
createAncestors: true,
|
||||
ignoreExisting: true,
|
||||
});
|
||||
await IOUtils.makeDirectory(audioRootDir(), {
|
||||
createAncestors: true,
|
||||
ignoreExisting: true,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user