Skip to content

Commit

Permalink
feat(mgrcd-io-fsa): add functions about voices
Browse files Browse the repository at this point in the history
  • Loading branch information
reosablo committed May 15, 2022
1 parent 37d5ae0 commit 7f2f292
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/mgrcd-io-fsa/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./image";
export * from "./model";
export * from "./scenario";
export * from "./voice";
36 changes: 36 additions & 0 deletions packages/mgrcd-io-fsa/src/voice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const voiceDirectoryPath = ["sound_native", "voice"] as const;
const fullVoiceDirectoryPath = ["sound_native", "fullVoice"] as const;

export async function* getVoiceFiles(
resourceDirectory: FileSystemDirectoryHandle,
) {
const voiceDirectory = await voiceDirectoryPath.reduce(
async (directory, name) => (await directory).getDirectoryHandle(name),
Promise.resolve(resourceDirectory),
);
for await (const [name, entry] of voiceDirectory.entries()) {
if (/\.hca/.test(name) && entry instanceof FileSystemFileHandle) {
yield [name, entry] as [
name: typeof name,
file: typeof entry,
];
}
}
}

export async function* getFullVoiceFiles(
resourceDirectory: FileSystemDirectoryHandle,
) {
const fullVoiceDirectory = await fullVoiceDirectoryPath.reduce(
async (directory, name) => (await directory).getDirectoryHandle(name),
Promise.resolve(resourceDirectory),
);
for await (const [name, entry] of fullVoiceDirectory.entries()) {
if (/\.hca/.test(name) && entry instanceof FileSystemFileHandle) {
yield [name, entry] as [
name: typeof name,
file: typeof entry,
];
}
}
}

0 comments on commit 7f2f292

Please sign in to comment.