@tskau/vtrans
yandex video translation API client written in typescript
disclaimer
this library is UNOFFICIAL and NOT MADE OR AUTHORIZED by
Yandex N.V. or ООО "ЯНДЕКС" (Yandex LLC).
this library is based on the results of reverse engineering
and implements a client for a private API that is
NOT INTENDED for use in software other than yandex.browser.
installation
npm install --save @tskau/vtrans
usage example
import { Client } from '@tskau/vtrans'
const client = new Client({ })
try {
const translationResult = await client.translate({
originalUrl: 'https://www.youtube.com/watch?v=rEQm1wU_b9M',
originalLanguage: 'ru',
translationLanguage: 'en'
})
if (translationResult.status === 'WORK_IN_PROGRESS') {
translationResult.remainingTime
}
if (translationResult.status === 'SUCCESS') {
await translationResult.translation.content.stream()
await translationResult.translation.content.save('/tmp/dolphin-naprosilis-english.mp3')
translationResult.translation.content.url
translationResult.translation.duration
}
} catch (error) {
console.log(error.message)
}
try {
const subtitlesResult = await client.getSubtitles({
originalUrl: 'https://www.youtube.com/watch?v=rEQm1wU_b9M',
originalLanguage: 'ru'
})
subtitlesResult.original.language
await subtitlesResult.original.content.stream()
await subtitlesResult.original.content.save('/tmp/dolphin-naprosilis-russian-yandex.json')
subtitlesResult.original.content.url
subtitlesResult.translations[0].language
await subtitlesResult.translations[0].content.stream()
await subtitlesResult.translations[0].content.save('/tmp/dolphin-naprosilis-english-yandex.json')
subtitlesResult.translations[0].content.url
} catch (error) {
console.log(error.message)
}
acknowledgements
all this exists thanks to Toil's implementation of the CLI/browser extension.
check out the vot-cli (CLI) or voice-over-translation (browser extension).