Skip to content

Commit

Permalink
new sequence audio2text-input
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrek6641 committed Jun 16, 2023
1 parent 0a8a280 commit d527fd2
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 0 deletions.
62 changes: 62 additions & 0 deletions typescript/audio2text-input/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Audio2text Input

This is another version which uses input channel instead of filesystem

The audio file
<a href="https://salford.figshare.com/collections/HARVARD_speech_corpus_-_audio_recording_2019/4437578" target="_blank">`song.wav`</a> is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.

___

## Description

This is a sequence which transript audio file using AssemblyAi API.

## Prerequisites

> ❗ Remember to [setup transform-hub locally](https://docs.scramjet.org/platform/self-hosted-installation) or use the [platform's environment](https://docs.scramjet.org/platform/quick-start) for the sequence deployment.
As this apps is using AssemblyAi Api, the key is required to use it. For informations how to get one please refer to [assemblyAi](https://www.assemblyai.com/)

## Running

Open the terminal and run the following commands:

```bash
# go to 'repo-checker' directory
cd typescript/audio2text-input

# install dependencies
npm install

# transpile TS->JS to dist/
npm run build

# Pack the Sequence into a gzip format
si seq pack dist

# Send the Sequence to the Transform-Hub, with a return <Sequence-id> value
si seq send dist.tar.gz

# Start a Sequence, with the AssemblyAi-key as an argument parameter
si seq start <Sequence-id> --args [\"<AssemblyAI-token>\"]

# upload file to a instance
si inst input - /path/to/your/file -e -t application/octet-stream

```

## Getting results

All the informations generated by this instance will be available at the log channel.

To get result simply type in console:

`si inst output - `

## Testing

to make testing easier the sequence contains file ready to be uploaded.

Logs when running this sequence with a sample file should look like this:

![screenshot](https://github.com/scramjetorg/platform-samples/assets/53794300/1184b241-b11f-4b5a-b169-94b21ffcd44a)
31 changes: 31 additions & 0 deletions typescript/audio2text-input/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "assembly",
"version": "1.0.0",
"description": "Sequence that uses AssemblyAi to transcript Audio sent by input channel",
"main": "index.js",
"scripts": {
"build": "tsc -p tsconfig.json",
"postbuild": "cp -r package.json dist/ && (cd dist && npm i --omit=dev)"
},
"keywords": [
"Ai",
"Stream",
"AssemblyAi"
],
"repository": {
"type": "git",
"url": "https://github.com/scramjetorg/platform-samples/tree/main/typescript/audio2text"
},
"author": "Piotr",
"license": "ISC",
"dependencies": {
"@scramjet/obj-logger": "^0.34.3",
"@scramjet/utility": "^0.33.5",
"axios": "^1.3.6",
"date-and-time": "^2.4.3"
},
"devDependencies": {
"@scramjet/types": "0.33.5",
"@types/node": "^20.2.5"
}
}
Binary file added typescript/audio2text-input/song.wav
Binary file not shown.
17 changes: 17 additions & 0 deletions typescript/audio2text-input/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ReadableApp } from "@scramjet/types";
import { Assembly } from "../../audio2text/src/utils/assembly";
import { Readable } from "stream";

const app: ReadableApp<any> = async function(input: Readable, apiKey: string) {
const assembly = new Assembly(apiKey);

assembly.logger.outputLogStream.pipe(this.logger.inputLogStream);

return assembly.processFile(input).then(res => {
this.logger.info("Result", res);

return res;
});
};

export default app;
11 changes: 11 additions & 0 deletions typescript/audio2text-input/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"lib": [ "ESNext" ],
"target": "ESNext",
"module": "CommonJS",
"outDir": "./dist",
"esModuleInterop": true,
"skipLibCheck": true,
"resolveJsonModule": true,
}
}

0 comments on commit d527fd2

Please sign in to comment.