Skip to content

Instantly share code, notes, and snippets.

View hellodit's full-sized avatar
🎯
Focusing

Asdita Prasetya hellodit

🎯
Focusing
View GitHub Profile
@hellodit
hellodit / main.go
Created July 11, 2021 04:52
Golang APM with Elastic
package main
import (
"encoding/json"
"io/ioutil"
"net/http"
"time"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
def speech_to_text_microphone(recognizer, microphone):
if not isinstance(recognizer, speech_recognition.Recognizer):
raise TypeError("`recognizer` must be `Recognizer` instance")
if not isinstance(microphone, speech_recognition.Microphone):
raise TypeError("`microphone` must be `Microphone` instance")
print("Say something!")
with microphone as source:
def get_weather_info(location):
try:
response = requests.get("http://api.weatherstack.com/current?access_key=ebd06089ca30cb46428616818d96d6ca&query="+location)
# If the response was successful, no Exception will be raised
result = response.json()
if 'success' in result and result['success'] == False:
raise TypeError("`Location not valid")
return result
except HTTPError as http_err: