├── README.md
├── backend
├── README.md
├── linux_requirements.txt
├── python_requirements.txt
├── server.py
└── server_test.py
├── frontend
├── .editorconfig
├── .gitignore
├── .vs
│ ├── DeepSpeech
│ │ └── v15
│ │ │ └── .suo
│ ├── VSWorkspaceState.json
│ └── slnx.sqlite
├── README.md
├── angular.json
├── e2e
│ ├── protractor.conf.js
│ ├── src
│ │ ├── app.e2e-spec.ts
│ │ └── app.po.ts
│ └── tsconfig.e2e.json
├── mozilla.jpg
├── package-lock.json
├── package.json
├── src
│ ├── app
│ │ ├── app-routing.module.ts
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ ├── app.module.ts
│ │ ├── app.service.spec.ts
│ │ └── app.service.ts
│ ├── assets
│ │ ├── .gitkeep
│ │ ├── mozilla.jpg
│ │ ├── mozilla1.jpg
│ │ ├── mozilla2.jpg
│ │ └── mozilla3.jpg
│ ├── browserslist
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── favicon.ico
│ ├── index.html
│ ├── karma.conf.js
│ ├── main.ts
│ ├── mozilla.jpg
│ ├── polyfills.ts
│ ├── styles.css
│ ├── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── tsconfig.json
└── tslint.json
└── images
└── deepSpeech-api.JPG
/README.md:
--------------------------------------------------------------------------------
1 | # DeepSpeech-API
2 |
3 | Project [DeepSpeech](https://github.com/mozilla/DeepSpeech) is an open source Speech-To-Text engine, using a model trained by machine learning techniques, based on [Baidu's Deep Speech research paper](https://arxiv.org/abs/1412.5567). Project DeepSpeech uses Google's [TensorFlow](https://www.tensorflow.org/) project to make the implementation easier.
4 |
5 | The intent of this project [DeepSpeech-API](https://github.com/AASHISHAG/DeepSpeech-API) is to enable the user to access DeepSpeech on a web browser. You can quickly install the dependencies on any platform (Windows/IOS/Linux) and start using it over the Web (Computer/Mobile).
6 |
7 | #### Installing DeepSpeech Python bindings
8 |
9 | ```
10 | $ pip3 install deepspeech
11 | ```
12 |
13 | #### Getting the pre-trained model
14 |
15 | If you want to use the pre-trained English model for performing speech-to-text, you can download it (along with other important inference material) from the [DeepSpeech releases page](https://github.com/mozilla/DeepSpeech/releases). Alternatively, you can run the following command to download and unzip the files in your current directory:
16 |
17 | ```bash
18 | wget -O - https://github.com/mozilla/DeepSpeech/releases/download/v0.3.0/deepspeech-0.3.0-models.tar.gz | tar xvfz -
19 | ```
20 |
21 | #### Runnning DeepSpeech-API
22 |
23 | ```
24 | [Frontend](https://github.com/AASHISHAG/DeepSpeech-API/tree/master/frontend)
25 | ```
26 |
27 | ```
28 | [Backend](https://github.com/AASHISHAG/DeepSpeech-API/tree/master/backend)
29 | ```
30 |
31 | 
32 |
--------------------------------------------------------------------------------
/backend/README.md:
--------------------------------------------------------------------------------
1 | ## DeepSpeech-API (Backend)
2 |
3 | This project was generated with [Python-3.6.0](https://www.python.org/downloads/release/python-360/).
4 |
5 | By-default the server runs on `localhost:8080`. This can be changed in server.py
6 |
7 | #### Installing Python bindings
8 |
9 | ```
10 | pip3 install -r python_requirements.txt
11 | ```
12 |
13 | #### Installing Linux dependencies
14 |
15 | The important Linux dependencies can be found in linux_requirements.
16 |
17 | ```
18 | xargs -a linux_requirements.txt sudo apt-get install
19 | ```
20 |
21 | #### Runnning the Server
22 |
23 | ```bash
24 | python3 server.py
25 | ```
--------------------------------------------------------------------------------
/backend/linux_requirements.txt:
--------------------------------------------------------------------------------
1 | libsndfile1
2 | software-properties-common
--------------------------------------------------------------------------------
/backend/python_requirements.txt:
--------------------------------------------------------------------------------
1 | python_speech_features
2 | tensorflow == 1.12.0
3 | progressbar2
4 | python-utils
5 | matplotlib
6 | setuptools
7 | flask_cors
8 | soundfile
9 | paramiko
10 | requests
11 | attrdict
12 | librosa
13 | tables
14 | pandas
15 | flask
16 | scipy
17 | numpy
18 | pyxdg
19 | wave
20 | sox
21 | bs4
22 | six
--------------------------------------------------------------------------------
/backend/server.py:
--------------------------------------------------------------------------------
1 | from flask import Flask
2 | from flask import jsonify
3 | from flask import request
4 | from scipy.io.wavfile import read as wavread
5 | from scipy.io.wavfile import write as wavwrite
6 | import numpy as np
7 | import wave
8 | import cgi
9 | import contextlib
10 | import base64
11 | import soundfile as sf
12 | from flask_cors import CORS, cross_origin
13 | import subprocess
14 |
15 | app = Flask(__name__)
16 | cors = CORS(app)
17 | app.config['CORS_HEADERS'] = 'Content-Type'
18 |
19 | @app.route('/', methods=['POST'])
20 | @cross_origin()
21 | def post():
22 | with open("file.wav", "wb") as vid:
23 | vid.write(request.data)
24 |
25 | proc = subprocess.Popen(
26 | "deepspeech --model models/output_graph.pbmm --alphabet models/alphabet.txt --lm models/lm.binary --trie models/trie --audio file.wav",
27 | shell=True, stdout=subprocess.PIPE, )
28 | output = proc.communicate()[0]
29 | print(output)
30 |
31 | return jsonify(
32 | username=output
33 | )
34 |
35 | @app.route('/file', methods=['POST'])
36 | @cross_origin()
37 | def post1():
38 | with open("file.wav", "wb") as vid:
39 | vid.write(request.data)
40 |
41 | proc = subprocess.Popen(
42 | "deepspeech --model models/output_graph.pbmm --alphabet models/alphabet.txt --lm models/lm.binary --trie models/trie --audio file.wav",
43 | shell=True, stdout=subprocess.PIPE, )
44 | output = proc.communicate()[0]
45 | print(output)
46 |
47 | return jsonify(
48 | username=output
49 | )
50 |
51 | if __name__ == '__main__':
52 | app.run(host='0.0.0.0', port=8080,debug=True)
--------------------------------------------------------------------------------
/backend/server_test.py:
--------------------------------------------------------------------------------
1 | import subprocess
2 | import uuid
3 | import scipy.io.wavfile
4 | from deepspeech import Model
5 | from flask import Flask
6 | from flask import jsonify
7 | from flask import request
8 | from flask_cors import CORS, cross_origin
9 |
10 | BEAM_WIDTH = 1024
11 | LM_WEIGHT = 0.75
12 | VALID_WORD_COUNT_WEIGHT = 1.85
13 | N_FEATURES = 26
14 | N_CONTEXT = 9
15 | MODEL_FILE = 'models/output_graph.pbmm'
16 | ALPHABET_FILE = 'models/alphabet.txt'
17 | LANGUAGE_MODEL = 'models/lm.binary'
18 | TRIE_FILE = 'models/trie'
19 |
20 | ds = Model(MODEL_FILE, N_FEATURES, N_CONTEXT, ALPHABET_FILE, BEAM_WIDTH)
21 | ds.enableDecoderWithLM(ALPHABET_FILE, LANGUAGE_MODEL, TRIE_FILE, LM_WEIGHT, VALID_WORD_COUNT_WEIGHT)
22 |
23 | app = Flask(__name__)
24 | cors = CORS(app)
25 | app.config['CORS_HEADERS'] = 'Content-Type'
26 |
27 | @app.route('/', methods=['POST'])
28 | @cross_origin()
29 | def post():
30 | fileName = 'file_'+str(uuid.uuid4())+'.wav'
31 | with open(fileName, "wb") as vid:
32 | vid.write(request.data)
33 |
34 | fs, audio = scipy.io.wavfile.read(fileName)
35 | processed_data = ds.stt(audio, fs)
36 |
37 | # proc = subprocess.Popen(
38 | # "deepspeech --model models/output_graph.pbmm --alphabet models/alphabet.txt --lm models/lm.binary --trie models/trie --audio fileName",
39 | # shell=True, stdout=subprocess.PIPE, )
40 | # output = proc.communicate()[0]
41 | # print(output)
42 |
43 | print(processed_data)
44 |
45 | return jsonify(
46 | username=processed_data
47 | )
48 |
49 | @app.route('/file', methods=['POST'])
50 | @cross_origin()
51 | def post1():
52 | fileName = 'file_'+str(uuid.uuid4())+'.wav'
53 | with open(fileName, "wb") as vid:
54 | vid.write(request.data)
55 |
56 | fs, audio = scipy.io.wavfile.read(fileName)
57 | processed_data = ds.stt(audio, fs)
58 |
59 | # proc = subprocess.Popen(
60 | # "deepspeech --model models/output_graph.pbmm --alphabet models/alphabet.txt --lm models/lm.binary --trie models/trie --audio fileName",
61 | # shell=True, stdout=subprocess.PIPE, )
62 | # output = proc.communicate()[0]
63 |
64 | print(processed_data)
65 |
66 | return jsonify(
67 | username=processed_data
68 | )
69 |
70 | if __name__ == '__main__':
71 | app.run(host='0.0.0.0', port=80,debug=True)
--------------------------------------------------------------------------------
/frontend/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see https://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/frontend/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 |
8 | # dependencies
9 | /node_modules
10 |
11 | # profiling files
12 | chrome-profiler-events.json
13 | speed-measure-plugin.json
14 |
15 | # IDEs and editors
16 | /.idea
17 | .project
18 | .classpath
19 | .c9/
20 | *.launch
21 | .settings/
22 | *.sublime-workspace
23 |
24 | # IDE - VSCode
25 | .vscode/*
26 | !.vscode/settings.json
27 | !.vscode/tasks.json
28 | !.vscode/launch.json
29 | !.vscode/extensions.json
30 |
31 | # misc
32 | /.sass-cache
33 | /connect.lock
34 | /coverage
35 | /libpeerconnection.log
36 | npm-debug.log
37 | yarn-error.log
38 | testem.log
39 | /typings
40 |
41 | # System Files
42 | .DS_Store
43 | Thumbs.db
44 |
--------------------------------------------------------------------------------
/frontend/.vs/DeepSpeech/v15/.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AASHISHAG/DeepSpeech-API/05a7095730ec126e276c5cd38705e4bed4c1fb36/frontend/.vs/DeepSpeech/v15/.suo
--------------------------------------------------------------------------------
/frontend/.vs/VSWorkspaceState.json:
--------------------------------------------------------------------------------
1 | {
2 | "ExpandedNodes": [
3 | "",
4 | "\\e2e",
5 | "\\e2e\\src"
6 | ],
7 | "SelectedNode": "\\e2e\\src\\app.e2e-spec.ts",
8 | "PreviewInSolutionExplorer": false
9 | }
--------------------------------------------------------------------------------
/frontend/.vs/slnx.sqlite:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AASHISHAG/DeepSpeech-API/05a7095730ec126e276c5cd38705e4bed4c1fb36/frontend/.vs/slnx.sqlite
--------------------------------------------------------------------------------
/frontend/README.md:
--------------------------------------------------------------------------------
1 | ## DeepSpeech-API (Frontend)
2 |
3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.1.4.
4 |
5 | It is assumed that backend is running on `localhost:80`, which can be changed in `src\app\app.service.ts`.
6 |
7 | ## Development server
8 |
9 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
10 |
11 | #### Installing dependencies
12 |
13 | The important Nodejs dependencies can be installed using below commands.
14 |
15 | ```
16 | curl -sL https://deb.nodesource.com/setup_12.x | bash -
17 | apt-get install nodejs
18 | npm install -g @angular/cli
19 | npm install @angular/cli --save
20 | npm install @angular/compiler-cli --save
21 | npm install --save-dev @angular-devkit/build-angular
22 | npm install @angular-devkit/core --save-dev
23 | npm install
24 | ```
--------------------------------------------------------------------------------
/frontend/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "DeepSpeech": {
7 | "root": "",
8 | "sourceRoot": "src",
9 | "projectType": "application",
10 | "prefix": "app",
11 | "schematics": {},
12 | "architect": {
13 | "build": {
14 | "builder": "@angular-devkit/build-angular:browser",
15 | "options": {
16 | "outputPath": "dist/DeepSpeech",
17 | "index": "src/index.html",
18 | "main": "src/main.ts",
19 | "polyfills": "src/polyfills.ts",
20 | "tsConfig": "src/tsconfig.app.json",
21 | "assets": [
22 | "src/favicon.ico",
23 | "src/assets"
24 | ],
25 | "styles": [
26 | "./node_modules/bootstrap/dist/css/bootstrap.min.css",
27 | "src/styles.css"
28 | ],
29 | "scripts": []
30 | },
31 | "configurations": {
32 | "production": {
33 | "fileReplacements": [
34 | {
35 | "replace": "src/environments/environment.ts",
36 | "with": "src/environments/environment.prod.ts"
37 | }
38 | ],
39 | "optimization": true,
40 | "outputHashing": "all",
41 | "sourceMap": false,
42 | "extractCss": true,
43 | "namedChunks": false,
44 | "aot": true,
45 | "extractLicenses": true,
46 | "vendorChunk": false,
47 | "buildOptimizer": true,
48 | "budgets": [
49 | {
50 | "type": "initial",
51 | "maximumWarning": "2mb",
52 | "maximumError": "5mb"
53 | }
54 | ]
55 | }
56 | }
57 | },
58 | "serve": {
59 | "builder": "@angular-devkit/build-angular:dev-server",
60 | "options": {
61 | "browserTarget": "DeepSpeech:build"
62 | },
63 | "configurations": {
64 | "production": {
65 | "browserTarget": "DeepSpeech:build:production"
66 | }
67 | }
68 | },
69 | "extract-i18n": {
70 | "builder": "@angular-devkit/build-angular:extract-i18n",
71 | "options": {
72 | "browserTarget": "DeepSpeech:build"
73 | }
74 | },
75 | "test": {
76 | "builder": "@angular-devkit/build-angular:karma",
77 | "options": {
78 | "main": "src/test.ts",
79 | "polyfills": "src/polyfills.ts",
80 | "tsConfig": "src/tsconfig.spec.json",
81 | "karmaConfig": "src/karma.conf.js",
82 | "styles": [
83 | "src/styles.css"
84 | ],
85 | "scripts": [],
86 | "assets": [
87 | "src/favicon.ico",
88 | "src/assets"
89 | ]
90 | }
91 | },
92 | "lint": {
93 | "builder": "@angular-devkit/build-angular:tslint",
94 | "options": {
95 | "tsConfig": [
96 | "src/tsconfig.app.json",
97 | "src/tsconfig.spec.json"
98 | ],
99 | "exclude": [
100 | "**/node_modules/**"
101 | ]
102 | }
103 | }
104 | }
105 | },
106 | "DeepSpeech-e2e": {
107 | "root": "e2e/",
108 | "projectType": "application",
109 | "prefix": "",
110 | "architect": {
111 | "e2e": {
112 | "builder": "@angular-devkit/build-angular:protractor",
113 | "options": {
114 | "protractorConfig": "e2e/protractor.conf.js",
115 | "devServerTarget": "DeepSpeech:serve"
116 | },
117 | "configurations": {
118 | "production": {
119 | "devServerTarget": "DeepSpeech:serve:production"
120 | }
121 | }
122 | },
123 | "lint": {
124 | "builder": "@angular-devkit/build-angular:tslint",
125 | "options": {
126 | "tsConfig": "e2e/tsconfig.e2e.json",
127 | "exclude": [
128 | "**/node_modules/**"
129 | ]
130 | }
131 | }
132 | }
133 | }
134 | },
135 | "defaultProject": "DeepSpeech"
136 | }
--------------------------------------------------------------------------------
/frontend/e2e/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './src/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: require('path').join(__dirname, './tsconfig.e2e.json')
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
--------------------------------------------------------------------------------
/frontend/e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('workspace-project App', () => {
4 | let page: AppPage;
5 |
6 | beforeEach(() => {
7 | page = new AppPage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getTitleText()).toEqual('Welcome to DeepSpeech!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/frontend/e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getTitleText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/frontend/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "jasminewd2",
10 | "node"
11 | ]
12 | }
13 | }
--------------------------------------------------------------------------------
/frontend/mozilla.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AASHISHAG/DeepSpeech-API/05a7095730ec126e276c5cd38705e4bed4c1fb36/frontend/mozilla.jpg
--------------------------------------------------------------------------------
/frontend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "deep-speech",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve",
7 | "build": "ng build",
8 | "test": "ng test",
9 | "lint": "ng lint",
10 | "e2e": "ng e2e"
11 | },
12 | "private": true,
13 | "dependencies": {
14 | "@angular/animations": "~7.1.0",
15 | "@angular/common": "~7.1.0",
16 | "@angular/compiler": "~7.1.0",
17 | "@angular/core": "~7.1.0",
18 | "@angular/forms": "~7.1.0",
19 | "@angular/platform-browser": "~7.1.0",
20 | "@angular/platform-browser-dynamic": "~7.1.0",
21 | "@angular/router": "~7.1.0",
22 | "bootstrap": "^4.2.1",
23 | "core-js": "^2.5.4",
24 | "ngx-spinner": "^6.1.2",
25 | "recordrtc": "^5.5.0",
26 | "rxjs": "~6.3.3",
27 | "tslib": "^1.9.0",
28 | "zone.js": "~0.8.26"
29 | },
30 | "devDependencies": {
31 | "@angular-devkit/build-angular": "~0.11.0",
32 | "@angular/cli": "~7.1.4",
33 | "@angular/compiler-cli": "~7.1.0",
34 | "@angular/language-service": "~7.1.0",
35 | "@types/node": "~8.9.4",
36 | "@types/jasmine": "~2.8.8",
37 | "@types/jasminewd2": "~2.0.3",
38 | "codelyzer": "~4.5.0",
39 | "jasmine-core": "~2.99.1",
40 | "jasmine-spec-reporter": "~4.2.1",
41 | "karma": "~3.1.1",
42 | "karma-chrome-launcher": "~2.2.0",
43 | "karma-coverage-istanbul-reporter": "~2.0.1",
44 | "karma-jasmine": "~1.1.2",
45 | "karma-jasmine-html-reporter": "^0.2.2",
46 | "protractor": "~5.4.0",
47 | "ts-node": "~7.0.0",
48 | "tslint": "~5.11.0",
49 | "typescript": "~3.1.6"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/frontend/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { AppComponent } from './app.component'
4 |
5 | const routes: Routes = [];
6 |
7 | @NgModule({
8 | imports: [RouterModule.forRoot(routes)],
9 | exports: [RouterModule]
10 | })
11 | export class AppRoutingModule { }
12 |
--------------------------------------------------------------------------------
/frontend/src/app/app.component.css:
--------------------------------------------------------------------------------
1 | #test{
2 | width:100%;
3 | background: url(src/assets/mozilla2.jpg) 50% 0 no-repeat fixed;
4 | background-size:cover;
5 | }
--------------------------------------------------------------------------------
/frontend/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |

4 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/frontend/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { RouterTestingModule } from '@angular/router/testing';
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | imports: [
9 | RouterTestingModule
10 | ],
11 | declarations: [
12 | AppComponent
13 | ],
14 | }).compileComponents();
15 | }));
16 |
17 | it('should create the app', () => {
18 | const fixture = TestBed.createComponent(AppComponent);
19 | const app = fixture.debugElement.componentInstance;
20 | expect(app).toBeTruthy();
21 | });
22 |
23 | it(`should have as title 'DeepSpeech'`, () => {
24 | const fixture = TestBed.createComponent(AppComponent);
25 | const app = fixture.debugElement.componentInstance;
26 | expect(app.title).toEqual('DeepSpeech');
27 | });
28 |
29 | it('should render title in a h1 tag', () => {
30 | const fixture = TestBed.createComponent(AppComponent);
31 | fixture.detectChanges();
32 | const compiled = fixture.debugElement.nativeElement;
33 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to DeepSpeech!');
34 | });
35 | });
36 |
--------------------------------------------------------------------------------
/frontend/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component , OnInit, Output } from '@angular/core';
2 | import * as RecordRTC from 'recordrtc';
3 | import { DomSanitizer } from '@angular/platform-browser';
4 | import {AppService} from './app.service';
5 | import { NgxSpinnerService } from 'ngx-spinner';
6 |
7 | @Component({
8 | selector: 'app-root',
9 | templateUrl: './app.component.html',
10 | styleUrls: ['./app.component.css']
11 | })
12 |
13 | export class AppComponent {
14 |
15 | fileToUpload: File = null;
16 | private record;
17 | recording = false;
18 | private url;
19 | private error;
20 | response ;
21 | isloader = false;
22 | text: string;
23 |
24 | constructor(private domSanitizer: DomSanitizer, private appService: AppService, private spinner: NgxSpinnerService) {
25 | }
26 |
27 | sanitize(url:string){
28 | return this.domSanitizer.bypassSecurityTrustUrl(url);
29 | }
30 |
31 | /**
32 | * Start recording.
33 | */
34 | initiateRecording() {
35 |
36 | this.recording = true;
37 | let mediaConstraints = {
38 | video: false,
39 | audio: true
40 | };
41 | navigator.mediaDevices
42 | .getUserMedia(mediaConstraints)
43 | .then(this.successCallback.bind(this), this.errorCallback.bind(this));
44 | }
45 |
46 | /**
47 | * Will be called automatically.
48 | */
49 | successCallback(stream) {
50 | var options = {
51 | mimeType: "audio/wav",
52 | numberOfAudioChannels: 1
53 | };
54 | //Start Actuall Recording
55 | var StereoAudioRecorder = RecordRTC.StereoAudioRecorder;
56 | this.record = new StereoAudioRecorder(stream, options);
57 | this.record.record();
58 | }
59 |
60 | /**
61 | * Stop recording.
62 | */
63 | stopRecording() {
64 | this.recording = false;
65 | this.record.stop(this.processRecording.bind(this));
66 | }
67 |
68 | /**
69 | * processRecording Do what ever you want with blob
70 | * @param {any} blob Blog
71 | */
72 | processRecording(blob) {
73 | this.isloader=true;
74 | this.spinner.show();
75 | this.url = URL.createObjectURL(blob);
76 | console.log(this.url)
77 | this.response = this.appService.save(blob).subscribe(result => {
78 | this.response = result;
79 | console.log('s ',this.response.username);
80 | this.text = this.response.username;
81 | this.isloader = false;
82 | this.spinner.hide();
83 | });
84 | }
85 |
86 | /**
87 | * Process Error.
88 | */
89 | errorCallback(error) {
90 | this.error = 'Can not play audio in your browser';
91 | }
92 |
93 | handleFileInput(files: FileList) {
94 | this.fileToUpload = files.item(0);
95 | this.uploadFileToActivity()
96 | }
97 |
98 | uploadFileToActivity() {
99 | this.isloader=true;
100 | this.spinner.show();
101 | this.appService.postFile(this.fileToUpload).subscribe(result => {
102 | this.response = result;
103 | console.log('s ',this.response.username);
104 | this.text = this.response.username;
105 | this.isloader = false;
106 | this.spinner.hide();
107 | });
108 | }
109 | }
--------------------------------------------------------------------------------
/frontend/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { HttpClientModule } from '@angular/common/http';
4 | import { AppRoutingModule } from './app-routing.module';
5 | import { AppComponent } from './app.component';
6 | import { AppService } from './app.service';
7 | import { NgxSpinnerModule } from 'ngx-spinner';
8 |
9 | @NgModule({
10 | declarations: [
11 | AppComponent
12 | ],
13 | imports: [
14 | BrowserModule,
15 | AppRoutingModule,
16 | HttpClientModule,
17 | NgxSpinnerModule
18 | ],
19 | providers: [AppService],
20 | bootstrap: [AppComponent]
21 | })
22 | export class AppModule { }
23 |
--------------------------------------------------------------------------------
/frontend/src/app/app.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed } from '@angular/core/testing';
2 | import { AppService } from './app.service';
3 |
4 | describe('ServiceService', () => {
5 | beforeEach(() => TestBed.configureTestingModule({}));
6 |
7 | it('should be created', () => {
8 | const service: AppService = TestBed.get(AppService);
9 | expect(service).toBeTruthy();
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/frontend/src/app/app.service.ts:
--------------------------------------------------------------------------------
1 | import { HttpClient, HttpParams } from '@angular/common/http';
2 | import { HttpHeaders } from '@angular/common/http';
3 | import { Injectable } from '@angular/core';
4 | import { Observable } from 'rxjs';
5 |
6 | const httpOptions = {
7 | headers: new HttpHeaders({
8 | 'Content-Type': 'application/json'
9 | })
10 | };
11 |
12 | @Injectable()
13 | export class AppService {
14 | constructor(private httpClient: HttpClient ) { }
15 | baseUrl: string = 'http://localhost:80/';
16 |
17 | save(blob: URL): Observable<{}>{
18 | return this.httpClient.post(this.baseUrl, blob, httpOptions).pipe(
19 | data => {
20 | return data;
21 | });
22 | }
23 |
24 | postFile(fileToUpload: File): Observable<{}> {
25 | console.log("inside upload file")
26 | const endpoint = this.baseUrl+'file';
27 | return this.httpClient.post(endpoint, fileToUpload, httpOptions).pipe(
28 | data => {
29 | return data;
30 | });
31 | }
32 | }
--------------------------------------------------------------------------------
/frontend/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AASHISHAG/DeepSpeech-API/05a7095730ec126e276c5cd38705e4bed4c1fb36/frontend/src/assets/.gitkeep
--------------------------------------------------------------------------------
/frontend/src/assets/mozilla.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AASHISHAG/DeepSpeech-API/05a7095730ec126e276c5cd38705e4bed4c1fb36/frontend/src/assets/mozilla.jpg
--------------------------------------------------------------------------------
/frontend/src/assets/mozilla1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AASHISHAG/DeepSpeech-API/05a7095730ec126e276c5cd38705e4bed4c1fb36/frontend/src/assets/mozilla1.jpg
--------------------------------------------------------------------------------
/frontend/src/assets/mozilla2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AASHISHAG/DeepSpeech-API/05a7095730ec126e276c5cd38705e4bed4c1fb36/frontend/src/assets/mozilla2.jpg
--------------------------------------------------------------------------------
/frontend/src/assets/mozilla3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AASHISHAG/DeepSpeech-API/05a7095730ec126e276c5cd38705e4bed4c1fb36/frontend/src/assets/mozilla3.jpg
--------------------------------------------------------------------------------
/frontend/src/browserslist:
--------------------------------------------------------------------------------
1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 | #
5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
6 |
7 | > 0.5%
8 | last 2 versions
9 | Firefox ESR
10 | not dead
11 | not IE 9-11
--------------------------------------------------------------------------------
/frontend/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/frontend/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false
7 | };
8 |
9 | /*
10 | * For easier debugging in development mode, you can import the following file
11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12 | *
13 | * This import should be commented out in production mode because it will have a negative impact
14 | * on performance if an error is thrown.
15 | */
16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
17 |
--------------------------------------------------------------------------------
/frontend/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AASHISHAG/DeepSpeech-API/05a7095730ec126e276c5cd38705e4bed4c1fb36/frontend/src/favicon.ico
--------------------------------------------------------------------------------
/frontend/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | DeepSpeech
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/frontend/src/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../coverage'),
20 | reports: ['html', 'lcovonly', 'text-summary'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false
30 | });
31 | };
--------------------------------------------------------------------------------
/frontend/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.error(err));
13 |
--------------------------------------------------------------------------------
/frontend/src/mozilla.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AASHISHAG/DeepSpeech-API/05a7095730ec126e276c5cd38705e4bed4c1fb36/frontend/src/mozilla.jpg
--------------------------------------------------------------------------------
/frontend/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10, IE11, and Chrome <55 requires all of the following polyfills.
22 | * This also includes Android Emulators with older versions of Chrome and Google Search/Googlebot
23 | */
24 |
25 | // import 'core-js/es6/symbol';
26 | // import 'core-js/es6/object';
27 | // import 'core-js/es6/function';
28 | // import 'core-js/es6/parse-int';
29 | // import 'core-js/es6/parse-float';
30 | // import 'core-js/es6/number';
31 | // import 'core-js/es6/math';
32 | // import 'core-js/es6/string';
33 | // import 'core-js/es6/date';
34 | // import 'core-js/es6/array';
35 | // import 'core-js/es6/regexp';
36 | // import 'core-js/es6/map';
37 | // import 'core-js/es6/weak-map';
38 | // import 'core-js/es6/set';
39 |
40 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
41 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
42 |
43 | /** IE10 and IE11 requires the following for the Reflect API. */
44 | // import 'core-js/es6/reflect';
45 |
46 | /**
47 | * Web Animations `@angular/platform-browser/animations`
48 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
49 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
50 | */
51 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
52 |
53 | /**
54 | * By default, zone.js will patch all possible macroTask and DomEvents
55 | * user can disable parts of macroTask/DomEvents patch by setting following flags
56 | * because those flags need to be set before `zone.js` being loaded, and webpack
57 | * will put import in the top of bundle, so user need to create a separate file
58 | * in this directory (for example: zone-flags.ts), and put the following flags
59 | * into that file, and then add the following code before importing zone.js.
60 | * import './zone-flags.ts';
61 | *
62 | * The flags allowed in zone-flags.ts are listed here.
63 | *
64 | * The following flags will work for all browsers.
65 | *
66 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
67 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
68 | * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
69 | *
70 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
71 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
72 | *
73 | * (window as any).__Zone_enable_cross_context_check = true;
74 | *
75 | */
76 |
77 | /***************************************************************************************************
78 | * Zone JS is required by default for Angular itself.
79 | */
80 | import 'zone.js/dist/zone'; // Included with Angular CLI.
81 |
82 |
83 | /***************************************************************************************************
84 | * APPLICATION IMPORTS
85 | */
86 |
--------------------------------------------------------------------------------
/frontend/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/frontend/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: any;
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting()
16 | );
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/);
19 | // And load the modules.
20 | context.keys().map(context);
21 |
--------------------------------------------------------------------------------
/frontend/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "types": []
6 | },
7 | "exclude": [
8 | "test.ts",
9 | "**/*.spec.ts"
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/frontend/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "test.ts",
12 | "polyfills.ts"
13 | ],
14 | "include": [
15 | "**/*.spec.ts",
16 | "**/*.d.ts"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/frontend/src/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "app",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "app",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/frontend/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "module": "es2015",
9 | "moduleResolution": "node",
10 | "emitDecoratorMetadata": true,
11 | "experimentalDecorators": true,
12 | "importHelpers": true,
13 | "target": "es5",
14 | "typeRoots": [
15 | "node_modules/@types"
16 | ],
17 | "lib": [
18 | "es2018",
19 | "dom"
20 | ]
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/frontend/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "deprecation": {
15 | "severity": "warn"
16 | },
17 | "eofline": true,
18 | "forin": true,
19 | "import-blacklist": [
20 | true,
21 | "rxjs/Rx"
22 | ],
23 | "import-spacing": true,
24 | "indent": [
25 | true,
26 | "spaces"
27 | ],
28 | "interface-over-type-literal": true,
29 | "label-position": true,
30 | "max-line-length": [
31 | true,
32 | 140
33 | ],
34 | "member-access": false,
35 | "member-ordering": [
36 | true,
37 | {
38 | "order": [
39 | "static-field",
40 | "instance-field",
41 | "static-method",
42 | "instance-method"
43 | ]
44 | }
45 | ],
46 | "no-arg": true,
47 | "no-bitwise": true,
48 | "no-console": [
49 | true,
50 | "debug",
51 | "info",
52 | "time",
53 | "timeEnd",
54 | "trace"
55 | ],
56 | "no-construct": true,
57 | "no-debugger": true,
58 | "no-duplicate-super": true,
59 | "no-empty": false,
60 | "no-empty-interface": true,
61 | "no-eval": true,
62 | "no-inferrable-types": [
63 | true,
64 | "ignore-params"
65 | ],
66 | "no-misused-new": true,
67 | "no-non-null-assertion": true,
68 | "no-redundant-jsdoc": true,
69 | "no-shadowed-variable": true,
70 | "no-string-literal": false,
71 | "no-string-throw": true,
72 | "no-switch-case-fall-through": true,
73 | "no-trailing-whitespace": true,
74 | "no-unnecessary-initializer": true,
75 | "no-unused-expression": true,
76 | "no-use-before-declare": true,
77 | "no-var-keyword": true,
78 | "object-literal-sort-keys": false,
79 | "one-line": [
80 | true,
81 | "check-open-brace",
82 | "check-catch",
83 | "check-else",
84 | "check-whitespace"
85 | ],
86 | "prefer-const": true,
87 | "quotemark": [
88 | true,
89 | "single"
90 | ],
91 | "radix": true,
92 | "semicolon": [
93 | true,
94 | "always"
95 | ],
96 | "triple-equals": [
97 | true,
98 | "allow-null-check"
99 | ],
100 | "typedef-whitespace": [
101 | true,
102 | {
103 | "call-signature": "nospace",
104 | "index-signature": "nospace",
105 | "parameter": "nospace",
106 | "property-declaration": "nospace",
107 | "variable-declaration": "nospace"
108 | }
109 | ],
110 | "unified-signatures": true,
111 | "variable-name": false,
112 | "whitespace": [
113 | true,
114 | "check-branch",
115 | "check-decl",
116 | "check-operator",
117 | "check-separator",
118 | "check-type"
119 | ],
120 | "no-output-on-prefix": true,
121 | "use-input-property-decorator": true,
122 | "use-output-property-decorator": true,
123 | "use-host-property-decorator": true,
124 | "no-input-rename": true,
125 | "no-output-rename": true,
126 | "use-life-cycle-interface": true,
127 | "use-pipe-transform-interface": true,
128 | "component-class-suffix": true,
129 | "directive-class-suffix": true
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/images/deepSpeech-api.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AASHISHAG/DeepSpeech-API/05a7095730ec126e276c5cd38705e4bed4c1fb36/images/deepSpeech-api.JPG
--------------------------------------------------------------------------------