Skip to content

Commit

Permalink
Merge pull request #39 from Simon-Tang/types
Browse files Browse the repository at this point in the history
Adds TypeScript type declarations
  • Loading branch information
discordier authored Apr 19, 2023
2 parents c2f4cd0 + dc5fd2c commit e037db2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": false,
"main": "dist/samjs.min.js",
"module": "dist/samjs.esm.min.js",
"types": "src/index.d.ts",
"scripts": {
"dev": "rollup -w -c build/config.js --environment TARGET:dev",
"dev:cjs": "rollup -w -c build/config.js --environment TARGET:cjs",
Expand Down
25 changes: 25 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
interface SamJsOptions {
phonetic?: boolean;
singmode?: boolean;
debug?: boolean;
pitch?: number;
speed?: number;
mouth?: number;
throat?: number;
}

interface SamJsSpeakPromise extends Promise<true> {
abort: (reason: any) => void;
}

declare class SamJs {
constructor(options?: SamJsOptions);
buf8(text: string, phonetic?: boolean): Uint8Array | Boolean;
buf32(text: string, phonetic?: boolean): Float32Array | Boolean;
speak(text: string, phonetic?: boolean): SamJsSpeakPromise;
download(text: string, phonetic?: boolean): void;
}

declare module "sam-js" {
export = SamJs;
}

0 comments on commit e037db2

Please sign in to comment.