-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (45 loc) · 1.72 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { writeFile, readFile } from 'fs/promises'
import { speak, recognize, translate, summarize, sentiment, keyphrases } from './api.js'
async function main() {
// ========================
// === Speech Synthesis ===
// ========================
const text = "Hi and thank you so much for paying a visit to this repository. It's been a pleasure to meet you!"
const speakBuffer = await speak(text, 5, 'cheerful', true)
// =======================
// === Writing to File ===
// =======================
const filename = 'test.wav'
await writeFile(filename, speakBuffer)
console.log('Wrote speech to file:', filename)
// ==========================
// === Speech Recognition ===
// ==========================
const recognitionResult = await recognize(speakBuffer)
console.log('Spoken text:', recognitionResult)
// ==========================
// === Speech Translation ===
// ==========================
const translationResult = await translate(speakBuffer, 'en-US', 'bn-IN')
console.log('Translated text:', translationResult)
// ==========================
// === Text Summarization ===
// ==========================
const prompt = await readFile('test.txt', 'utf8')
const summarizationResult = await summarize(prompt, 1, 'en')
console.log('Summary:')
console.log(summarizationResult)
// ===========================
// === Sentiment Detection ===
// ===========================
const emotion = await sentiment('আমার মন খারাপ', 'bn')
console.log('Sentiment:')
console.log(emotion)
// ============================
// === Keyphrase Extraction ===
// ============================
const keyphasesResult = await keyphrases(prompt, 'en')
console.log('Keyphrases:')
console.log(keyphasesResult)
}
main()