Skip to content

Instantly share code, notes, and snippets.

@phsultan
phsultan / index.html
Last active September 27, 2021 19:04
How to use Susbspace's TURN servers with Tokbox (TADHack 2021)
<html>
<head>
<title>Publish to Vonage, via Subspace TURN network</title>
<link href="css/app.css" rel="stylesheet" type="text/css">
<script>
class turnSubspaceRTCPeerConnection extends RTCPeerConnection {
constructor(configuration) {
configuration.iceTransportPolicy = 'relay'
configuration.iceServers = [
{
const speech = require('@google-cloud/speech');
const fs = require('fs');
const logger = console;
class GoogleSpeech
{
constructor()
{
logger.debug('constructor()');
/**
* Copyright 2017, Google, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@phsultan
phsultan / testApiKeyAndGrpc.js
Last active August 2, 2023 12:54
Google Speech Recognition with API key + gRPC
/**
* Make sure you're not already authenticated with gRPC, on MacOS you need
* to ensure the GOOGLE_APPLICATION_CREDENTIALS environment variable is not
* set : `unset GOOGLE_APPLICATION_CREDENTIALS`
*
* @google-cloud/speech and google-gax are used to load the necessary .proto files
*
* I tried to add the 'key' to the request itself, or as a metadata with the request
* and always getting the following error from gRPC :
* Error: 7 PERMISSION_DENIED: The request is missing a valid API key.
@phsultan
phsultan / testApiKeyAndAxios.js
Created April 12, 2018 09:36
Google Speech Recognition with API key + axios
const fs = require('fs');
const axios = require('axios');
const API_KEY = 'ADD YOUR API KEY HERE';
const fileName = './audio.raw';
// Reads a local audio file and converts it to base64
const file = fs.readFileSync(fileName);
const audioBytes = file.toString('base64');
@phsultan
phsultan / testApiKeyAndGoogleAuthLibrary.js
Created April 12, 2018 09:34
Google Speech Recognition with API key + google-auth-library
const fs = require('fs');
const { auth } = require('google-auth-library');
const API_KEY = 'ADD YOUR API KEY HERE';
const fileName = './audio.raw';
// Reads a local audio file and converts it to base64
const file = fs.readFileSync(fileName);
const audioBytes = file.toString('base64');