-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
39 lines (31 loc) · 907 Bytes
/
server.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
const express = require("express");
const { createClient } = require("@deepgram/sdk");
const cors = require("cors");
const app = express();
app.use(express.json());
app.use(cors());
const deepgramApiKey = process.env.NEXT_PUBLIC_DEEPGRAM_API_KEY;
// Create a route to transcribe the audio file from a URL
app.post("/transcribe", async (req, res) => {
try {
const deepgram = createClient('8cc9ccf3f80180c38daa46a82dabb942237689a6');
const { url } = req.body;
console.log(url);
const { result, error } = await deepgram.listen.prerecorded.transcribeUrl(
{
url,
},
{
smart_format: true,
model: "nova-2",
}
);
if (error) throw error;
res.json(result);
} catch (err) {
res.status(500).json({ error: err.message });
}
});
app.listen(3000, () => {
console.log("Express server is running on http://localhost:3000");
});