Skip to content

Instantly share code, notes, and snippets.

View ericlewis's full-sized avatar

Eric Lewis ericlewis

View GitHub Profile
(?i)(shazam (this|that|the) song|identify (this|that|the) song|what('s| is)? (this|that|the) song|name (this|that|the) tune|(do|can|could|may|would) you (know|tell|identify|figure out) what( this| that| the)? song (is|playing)|which song is (this|that|the)|what track is (playing|this|that|the) (right now)?|listen to (this|that|the) and tell me what (it|this|that|the) is|find out the name of (this|that|the) song|(help me recognize|help me shazam) (this|that|the) song|what('s| is)? the name of (this|that|the) (jam|track)|id (this|that|the) song|what song am I hearing)
package com.example.shazamwrapper;
import android.content.Context;
import com.shazam.shazamkit.AudioSampleRateInHz;
import com.shazam.shazamkit.Catalog;
import com.shazam.shazamkit.DeveloperToken;
import com.shazam.shazamkit.DeveloperTokenProvider;
import com.shazam.shazamkit.MatchResult;
import com.shazam.shazamkit.Session;
package humaneinternal.system.voice;
import android.content.Context;
import androidx.annotation.NonNull;
import com.shazam.shazamkit.AudioSampleRateInHz;
import com.shazam.shazamkit.Catalog;
import com.shazam.shazamkit.DeveloperToken;
import com.shazam.shazamkit.DeveloperTokenProvider;
@ericlewis
ericlewis / r.sh
Last active August 22, 2024 16:32
export PATH="/opt/homebrew/bin:$PATH"
export CFLAGS="-I/opt/homebrew/opt/openssl/include"
export LDFLAGS="-L/opt/homebrew/opt/openssl/lib"
git clone https://github.com/bkerler/mtkclient
cd mtkclient
python3.9 -m venv mtk_venv
source mtk_venv/bin/activate
import * as SecureStore from 'expo-secure-store';
import AsyncStorage from '@react-native-async-storage/async-storage';
class EphemeralSecureStore {
static prefix = "EphemeralSecureStore";
static getEphemeralKey(key) {
return `${this.prefix}_${key}`;
}
@ericlewis
ericlewis / ContentView.swift
Last active May 10, 2023 13:11
Dynamic Island Progress Demo in SwiftUI. Demo here: https://twitter.com/ericlewis/status/1656283504747880451
import SwiftUI
let size: CGSize = {
return .init(width: 126.0, height: 36.9)
}()
let origin: CGPoint = {
return .init(x: UIScreen.main.bounds.midX - 0.3, y: 29.4)
}()
@ericlewis
ericlewis / .directions.md
Last active October 25, 2023 18:25
A conversational chatbot experience.

Prerequisites

  • API key for OpenAI.
  • API key for Picovoice
  • API key for ElevenLabs
  • mpg123 installed
  • node 18+

Directions

  • git clone https://gist.github.com/ericlewis/ccd3f0b7a17fcbe2473121a473082c8f
  • edit .env with your keys
@ericlewis
ericlewis / WKChatGPT.swift
Created December 22, 2022 18:58
A way of using ChatGPT with SwiftUI
import SwiftUI
import WebKit
// MARK: Observable Object
public class Chat: NSObject, ObservableObject {
internal var webView: WKWebView
private var decoder: JSONDecoder = {
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
@ericlewis
ericlewis / index.js
Last active June 29, 2022 06:07
Example of having Morgan Freeman explain what code is doing using OpenAI Codex DaVinci & Uberduck's style transfer APIs.
import { Configuration, OpenAIApi } from "openai";
import download from "download";
import ora from "ora";
import soundPlayer from "play-sound"
import prompts from "prompts";
// Get your own keys, nerd.
const kOpenAI = "YOUR_API_KEY";
const kUberDuck = "PRIVATE_KEY:PUBLIC_KEY";
extension Published: Encodable where Value: Encodable {
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
let value = _PublishedValueExtractor.shared.extractValue(from: self)
try container.encode(value)
}
}
fileprivate struct _PublishedValueExtractor {
static let shared = _PublishedValueExtractor()