From: Andrew Gundersen Date: Wed, 3 Feb 2021 16:55:42 +0000 (-0600) Subject: cleaning some things up X-Git-Tag: v0.9~100^2~8 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=9bf01c0a3381abaa7f2a32e777322be870f0c615;p=mime-chat cleaning some things up --- diff --git a/gcloud.json b/gcloud.json deleted file mode 100644 index 5c68549..0000000 --- a/gcloud.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "service_account", - "project_id": "crimata", - "private_key_id": "3a324fa3fcca4cea589e4b5007f4142db4b3a84d", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCxFJOjhIkYlyhn\nHjtpFC5EOwzNFZem6k6SS7zcgWbNLe9mcBsiTKCjpxItzkIo0pnT32yqw+AKsqpv\n6+LVyzzjfB7vtEUflvg6KgmYMS4ixOTCEbN3e2qj1t2RnITXZR2VGSGdoKKyqZm0\ntWrmexQvSN20cByL1vfxD3E69oYFGhVraa0zmm94WXHAzofT6DkvGdrbK1s1G9jI\nG3mdQ1jN71tghyloeHL+R/1iKQoZFYTkVe6yWvccSNAZelt/5sciCKRTCArXj89X\nLwU6jGOKIsyqx3BeUyWaSS59xpnGX3meSf5Q9U+j45ePUiqO6TTleF+kWiBwjUpp\nfeYcwEIDAgMBAAECggEAElkN9R7p75zV6F1XDYu0QYiWyncmx/o2Gu1zC6vywWa1\ni/korpSe/mX0ub9J1p3/p1balRUHlUQu6brYvYs56140fGTC1sOXQ7uQU+8glySs\niTk5TbOBeKluOsSrdP/6oTTB6Wm4AegVz4YOpgPxsvaLVkNZidnDxfvyIQhjGYsO\nsvRaw48eEmGOa1uvDhgvPOxiDp5YEdxqSue/7ylzjBdKecDyLgTSDDf/p+FwIx5B\n2d/0uRgQBaAk6D/DNOvN8GrYyakFmlDjE72nrBGAJq50UyV6THOSDk+8cK+2QiS1\nEDCFufj+7Dk1EBfBFUFY8ZBB/pphpEWyLoFl7NzGCQKBgQDaj/KOOcj6BkkTj1WM\nRW3KhOE3nhsCQEgQGCflpycEAZj6J7ktBG2/4teDt9sr+Epx8ymnQCZa9pmysdrD\nU0aWku1qUx0IUKTtZbAEbB+AnrWYDYkIWU8kRUUvNHNTBg43VyuohV9wprPih138\nHWMeNac82/XICz2A3rv+Xkx8KwKBgQDPaaEEGWVs3nIhf/p3M3/xWNKt8fhAERpG\n0YpTjgHW3FQFYjiCTTIcuLO3qsDGmfIAB9tL37s2Y3e2wKBGUj/o69Fr7sWVPdsX\nJtUc0+KiG2Bs0hsyZPdk9UQiQX8y2eq1NZW7vEoxWso1bM64WURB5N8ocWePNJJx\nL2Oe75rtiQKBgQDLfQQOiRxmNF3rOSMkAywyRr9NQgXRdbniSiszNQotP7OHDF7q\n29m2suOGfjIv4O6m4wdf8WkEfd4hsleETc9Ft6wVtyYrrLGxWWCk7WnzHVDjLY7s\n2AHIOjostf+9R8EKoz1BnFN8laibev71EQNMiBWZow1VX6m2hymurWs2mwKBgQCb\nuY3n2v14qOb92e1+U89KsEq1yMd/qpeU9jwqEaO14wS+aglNY5ItWEuuqWhFdE3q\n0ftHUzpnUnUOZD+xrI1JXsyEgegc7i0xi7lUBI3S8kUKTxGWW5IXXcKDCbPrxQtg\ndFPweSUnOyg4xnHKnVMPOjyGS+bZ8TnF+zOLoBAtKQKBgF6hAOIwF1DheXT4p8xS\nlSGhl8dBxjsJDVwbnFWQceGzGnq1e3ncy/UItt42UCDVRWTH4r7pQ9eKyd/3foUD\n6KDIcCrYo2KJh6ZNFJ67XF30U+TuEg5U/9jTbWqDOwYVXcMcnzQE4ZiGBxVHL6xr\nNc8FRW5+7xh4zNfzhGUGt5kt\n-----END PRIVATE KEY-----\n", - "client_email": "crimata-service-account@crimata.iam.gserviceaccount.com", - "client_id": "102914612880037864172", - "auth_uri": "https://accounts.google.com/o/oauth2/auth", - "token_uri": "https://oauth2.googleapis.com/token", - "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", - "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/crimata-service-account%40crimata.iam.gserviceaccount.com" -} diff --git a/src/App.vue b/src/App.vue index 00294f1..1c8217a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,11 +5,12 @@ diff --git a/src/components/voiceBackground/index.vue b/src/components/voiceBackground/index.vue deleted file mode 100644 index 124a541..0000000 --- a/src/components/voiceBackground/index.vue +++ /dev/null @@ -1,127 +0,0 @@ - - - diff --git a/src/main.ts b/src/main.ts index bc2fa9d..531bb90 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,6 @@ import { createApp } from "vue"; import App from "./App.vue"; import router from "./router"; -import store from "./store"; // animation library import anime from "animejs"; @@ -11,7 +10,6 @@ import mitt from "mitt"; const emitter = mitt(); createApp(App) - .use(store) .use(router) .provide("animejs", anime) .provide("mitt", emitter) diff --git a/src/router/index.ts b/src/router/index.ts index cbb87ab..b44e9eb 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,4 +1,10 @@ -import { createRouter, createWebHistory, createWebHashHistory, RouteRecordRaw } from "vue-router"; +import { + createRouter, + createWebHistory, + createWebHashHistory, + RouteRecordRaw +} from "vue-router"; + import HomeIndex from "../views/home/index.vue"; const routes: Array = [ diff --git a/testAudio.js b/testAudio.js deleted file mode 100644 index 6a92222..0000000 --- a/testAudio.js +++ /dev/null @@ -1,114 +0,0 @@ -const fs = require('fs'); -// const portAudio = require('naudiodon'); -// Imports the Google Cloud client library -const speech = require('@google-cloud/speech'); -const portAudio = require('naudiodon'); - -// Create a stream to pipe into the AudioOutput -// Note that this does not strip the WAV header so a click will be heard at the beginning -const rs = fs.createReadStream('rawAudio.wav'); -const WebSocket = require("ws") -// Start piping data and start streaming -const {Writable} = require('stream'); -const ws = new WebSocket("ws://localhost:8080"); -//const duplex = WebSocket.createWebSocketStream(ws, { encoding: 'binary' }); - -const audioChunks = []; -const audioInputStreamTransform = new Writable({ - write(chunk, encoding, next) { - console.log(chunk) - // ws send chunk - // audioChunks.push(chunk); - // ws.send(chunk) - next(); - }, - - final() { - console.log(audioChunks) - // ws.send("stop") - // stop ws transer - }, -}); - - -// Creates a client -const client = new speech.SpeechClient(); - -/** - * TODO(developer): Uncomment the following lines before running the sample. - */ -const filename = './rawAudio.wav'; -const encoding = 'LINEAR16'; -const sampleRateHertz = 44100; -const languageCode = 'en-US'; - -const config = { - encoding: encoding, - sampleRateHertz: sampleRateHertz, - languageCode: languageCode, -}; -const audio = { - content: fs.readFileSync(filename).toString('base64'), -}; - -// const request = { -// config: config, -// audio: audio, -// }; - -// Detects speech in the audio file -async function test() { - const [response] = await client.recognize(request); - const transcription = response.results - .map(result => result.alternatives[0].transcript) - .join('\n'); - console.log('Transcription: ', transcription); -} - -// test(); - -const request = { - config, - interimResults: true, -}; - -const speechCallback = (data) => { - console.log( - `Transcription: ${data.results[0].alternatives[0].transcript}` - ) -} - -const recognizeStream = client -.streamingRecognize(request) -.on('error', err => { - if (err.code === 11) { - // restartStream(); - } else { - console.error('API request error ' + err); - } -}) -.on('data', speechCallback); - -// Create an instance of AudioIO with inOptions (defaults are as below), which will return a ReadableStream -const audioOptions = { - channelCount: 1, - sampleFormat: portAudio.sampleFormat16Bit, - sampleRate: 16000, - deviceId: -1, // Use -1 or omit the deviceId to select the default device - closeOnError: false // Close the stream if an audio error is detected, if set false then just log the error -} - -const audioData = []; -const ai = new portAudio.AudioIO({ - inOptions: audioOptions -}); -// ai.on('data', (d) => { -// audioData.push(d.toString('binary')) -// }) -ai.pipe(audioInputStreamTransform) -ai.start(); -setTimeout(() => { - ai.quit(); -}, 2000) - - diff --git a/testServer.js b/testServer.js deleted file mode 100644 index 03e4a04..0000000 --- a/testServer.js +++ /dev/null @@ -1,44 +0,0 @@ -const WebSocket = require("ws"); - -const testMessage = { - content: 'Hello from test server!' , - context: 'test message', - subContext: '', - modifiers: 'ai', - id: "0", - time: 'test' -} -const wss = new WebSocket.Server({ - port: 8080 - // perMessageDeflate: { - // zlibDeflateOptions: { - // // See zlib defaults. - // chunkSize: 1024, - // memLevel: 7, - // level: 3 - // }, - // zlibInflateOptions: { - // chunkSize: 10 * 1024 - // }, - // // Other options settable: - // clientNoContextTakeover: true, // Defaults to negotiated value. - // serverNoContextTakeover: true, // Defaults to negotiated value. - // serverMaxWindowBits: 10, // Defaults to negotiated value. - // // Below options specified as default values. - // concurrencyLimit: 10, // Limits zlib concurrency for perf. - // threshold: 1024 // Size (in bytes) below which messages - // // should not be compressed. - // } -}); - -wss.on("connection", function connection(ws, req) { - ws.on("message", function incoming(message) { - console.log(message) - // const parsed = JSON.parse(message) - // console.log(parsed) - }); - - const ip = req.socket.remoteAddress; - console.log("received connection from", ip); - ws.send(JSON.stringify(testMessage)); -}); diff --git a/ws.py b/ws.py deleted file mode 100644 index 939d01c..0000000 --- a/ws.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env python - -# WS server example - -import asyncio -import websockets - -# Imports the Google Cloud client library -from google.cloud import speech - -# Instantiates a client -client = speech.SpeechClient() - - -# config = speech.RecognitionConfig( -# encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16, -# sample_rate_hertz=16000, -# language_code="en-US", -# ) - -# streaming_config = speech.StreamingRecognitionConfig(config=config) - -# def transcribe(stream): - -# requests = ( -# speech.StreamingRecognizeRequest(audio_content=chunk) for chunk in stream -# ) - -# # Detects speech in the audio file -# responses = client.streaming_recognize( -# config=config, -# requests=requests -# ) - -# for response in responses: -# # Once the transcription has settled, the first result will contain the -# # is_final result. The other results will be for subsequent portions of -# # the audio. -# for result in response.results: -# print("Finished: {}".format(result.is_final)) -# print("Stability: {}".format(result.stability)) -# alternatives = result.alternatives -# # The alternatives are ordered from most likely to least. -# for alternative in alternatives: -# print("Confidence: {}".format(alternative.confidence)) -# print(u"Transcript: {}".format(alternative.transcript)) - - -speechtotext_client = speech.SpeechClient() - -config = speech.RecognitionConfig( - audio_channel_count=1, - encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16, - sample_rate_hertz=44100, - language_code="en-US", -) - -# Transcribe an audio file. -def transcribe(content): - input(content) - input(type(content)) - - content = speech.RecognitionAudio(content=content) - - # Detects speech in the audio file - response = speechtotext_client.recognize(config=config, audio=content) - input(f"Response: {response}") - - for result in response.results: - return result.alternatives[0].transcript - - -async def session(websocket, path): - buf = [] - - while True: - chunk = await websocket.recv() - - if chunk == "stop": - break - - buf.append(chunk) - - input(f"Buffer sample: {buf[0]}") - audio = b"".join(buf) - - transcribe(audio) - - -start_server = websockets.serve(session, "localhost", 8080) -asyncio.get_event_loop().run_until_complete(start_server) -asyncio.get_event_loop().run_forever()