-
-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from n4ze3m/next
v1.4.5
- Loading branch information
Showing
12 changed files
with
144 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
piplelineTransformer, | ||
//@ts-ignore | ||
} from "../../../utils/pipleline.js"; | ||
import { WaveFile } from "wavefile"; | ||
|
||
function _convert(audio: Buffer) { | ||
const wav = new WaveFile(audio); | ||
wav.toBitDepth("32f"); | ||
wav.toSampleRate(16000); | ||
let audioData = wav.getSamples(); | ||
if (Array.isArray(audioData)) { | ||
console.log( | ||
"Multiple channels detected. Selecting the first channel only." | ||
); | ||
audioData = audioData[0]; | ||
} | ||
return audioData; | ||
} | ||
|
||
export const convertTextToAudio = async (audioData: Buffer) => { | ||
const pipeline = await piplelineTransformer(); | ||
const transcriber = await pipeline( | ||
"automatic-speech-recognition", | ||
process.env.WHISPER_MODEL || "distil-whisper/distil-medium.en" | ||
); | ||
|
||
const audio = _convert(Buffer.from(audioData)); | ||
let output = (await transcriber(audio, { | ||
chunk_length_s: 30, | ||
})) as { | ||
text: string; | ||
}; | ||
|
||
return output; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -497,6 +497,11 @@ | |
dependencies: | ||
google-gax "^3.5.8" | ||
|
||
"@grammyjs/files@^1.0.4": | ||
version "1.0.4" | ||
resolved "https://registry.yarnpkg.com/@grammyjs/files/-/files-1.0.4.tgz#255d8e92bde0f43768840b80a230394f0a97dba6" | ||
integrity sha512-GT7JWRH9cs5kIrBtUGwMwVEhb1w7Vtnc93UT3zM/HYigmeVd93wWaIqyuSYsZq1VIB+9CSk0oz+ZsnxK83z7tg== | ||
|
||
"@grammyjs/[email protected]": | ||
version "3.1.1" | ||
resolved "https://registry.yarnpkg.com/@grammyjs/types/-/types-3.1.1.tgz#dd80c018ffaf44bd89c56160edb3d9e86b84251f" | ||
|