Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-ang committed Oct 16, 2022
1 parent c8a3649 commit f5b1102
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ app.post("/", async (req, res) => {
let audioURL = "";
let transcriptId = "";
let status = "";
// Upload audio file to AssemblyAI
console.log("Uploading audio file to AssemblyAI...");
assembly
.post("/upload", data)
.then((response) => {
Expand All @@ -48,6 +50,8 @@ app.post("/", async (req, res) => {
})
.then((response) => {
transcriptId = response.data.id;
// Transcribe audio file
console.log("Transcribing audio file...");
assembly
.get(`/transcript/${transcriptId}`)
.then(async (response) => {
Expand All @@ -57,6 +61,7 @@ app.post("/", async (req, res) => {
const response = await assembly.get(`/transcript/${transcriptId}`);
status = response.data.status;
if (status === "completed") {
console.log("Transcription complete!");
fs.unlink(audioFile, (err) => {
if (err)
throw err;
Expand Down
6 changes: 5 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ app.post("/", async (req, res) => {
let transcriptId = "";
let status = "";

// Upload audio file to AssemblyAI
console.log("Uploading audio file to AssemblyAI...");
assembly
.post("/upload", data)
.then((response) => {
Expand All @@ -55,20 +57,22 @@ app.post("/", async (req, res) => {
})
.then((response) => {
transcriptId = response.data.id;
// Transcribe audio file
console.log("Transcribing audio file...");
assembly
.get(`/transcript/${transcriptId}`)
.then(async (response) => {
status = response.data.status;

while (status !== "completed") {
await sleep(2000);

const response = await assembly.get(
`/transcript/${transcriptId}`
);
status = response.data.status;

if (status === "completed") {
console.log("Transcription complete!");
fs.unlink(audioFile, (err) => {
if (err) throw err;
console.log(`${audioFile} was deleted`);
Expand Down

0 comments on commit f5b1102

Please sign in to comment.