aboutsummaryrefslogtreecommitdiff
path: root/src/client/cognitive_services/CognitiveServices.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-07-26 02:39:43 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-07-26 02:39:43 -0400
commit3152e69dfafe1c393bed38f3aad1e55881e62a33 (patch)
tree4d92c86655ca74d1b9cd1ed6e528e32073e20f61 /src/client/cognitive_services/CognitiveServices.ts
parente1c7add158ce245ce6cb557177986b31fe107dd8 (diff)
initial commit
Diffstat (limited to 'src/client/cognitive_services/CognitiveServices.ts')
-rw-r--r--src/client/cognitive_services/CognitiveServices.ts27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/client/cognitive_services/CognitiveServices.ts b/src/client/cognitive_services/CognitiveServices.ts
index d69378d0e..40bbe55a1 100644
--- a/src/client/cognitive_services/CognitiveServices.ts
+++ b/src/client/cognitive_services/CognitiveServices.ts
@@ -9,6 +9,10 @@ import { Utils } from "../../Utils";
import { CompileScript } from "../util/Scripting";
import { ComputedField } from "../../new_fields/ScriptField";
import { InkData } from "../../new_fields/InkField";
+import "microsoft-cognitiveservices-speech-sdk";
+import "fs";
+import { AudioInputStream } from "microsoft-cognitiveservices-speech-sdk";
+import { createReadStream, ReadStream } from "fs";
type APIManager<D> = { converter: BodyConverter<D>, requester: RequestExecutor, analyzer: AnalysisApplier };
type RequestExecutor = (apiKey: string, body: string, service: Service) => Promise<string>;
@@ -22,7 +26,8 @@ export type Rectangle = { top: number, left: number, width: number, height: numb
export enum Service {
ComputerVision = "vision",
Face = "face",
- Handwriting = "handwriting"
+ Handwriting = "handwriting",
+ Transcription = "transcription"
}
export enum Confidence {
@@ -232,4 +237,24 @@ export namespace CognitiveServices {
}
+ export namespace Transcription {
+
+ export const Manager: APIManager<string> = {
+
+ converter: (data: string) => data,
+
+ requester: async (apiKey: string, body: string, service: Service) => {
+ let analysis = await fetch(`${RouteStore.audioData}/${body}`).then(async response => JSON.parse(await response.json()));
+ console.log(analysis);
+ return "";
+ },
+
+ analyzer: async (doc: Doc, keys: string[], filename: string) => {
+ let results = await executeQuery<string, any>(Service.Transcription, Manager, filename);
+ }
+
+ };
+
+ }
+
} \ No newline at end of file