Skip to content

Instantly share code, notes, and snippets.

@Gabriel-Chen
Gabriel-Chen / get_loc_googlemaps.py
Created June 27, 2018 16:57
Get Geo Location For a List of Address From Googlemaps API
import json
import os
import sys
import googlemaps
from keys import google_map_key
# google map credential
gmaps = googlemaps.Client(key=google_map_key)
def convert (feed):
@Gabriel-Chen
Gabriel-Chen / speech-to-text.sh
Created June 25, 2018 16:30
Convert Recording to Text
#!/bin/bash
echo “Recording… Press Ctrl+C to Stop.”
arecord -D “plughw:1,0” -q -f cd -t wav | ffmpeg -loglevel panic -y -i – -ar 16000 -acodec flac file.flac > /dev/null 2>&1
echo “Processing…”
wget -q -U “Mozilla/5.0” –post-file file.flac –header “Content-Type: audio/x-flac; rate=16000” -O – “http://www.google.com/speech-api/v1/recognize?lang=en-us&client=chromium” | cut -d -f12 >stt.txt
echo -n “You Said: ”
cat stt.txt
@Gabriel-Chen
Gabriel-Chen / degree-to-decimal.py
Created June 24, 2018 06:16
Convert Geometry Information in a Json File from Degree Format into Decimal Format
import re
import json
import pickle
def to_decimal (loc):
if type(loc) != str:
loc = str(loc)
if re.match('.*deg.*', loc):
loc_list = re.split('[-deg\''']+', loc)
if loc_list[0] == '':
@Gabriel-Chen
Gabriel-Chen / csv-remove-accent.py
Created June 24, 2018 06:06
Remove All Accent on Letters in a CSV File
# This gist is initially used for analysing data in Spanish
import unidecode
import csv
def remove_accent (feed):
csv_f = open(feed, encoding='latin-1', mode='r')
csv_str = csv_f.read()
csv_str_removed_accent = unidecode.unidecode(csv_str)
csv_f.close()