Google APIS
User Auth
On the Backend
Setup
Usage
API Auth
Speech to Text
Image to Object Labels
Text to Speech
Last updated
Last updated
import io
import os
# Imports the Google Cloud client library
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
# Instantiates a client
client = speech.SpeechClient()
# The name of the audio file to transcribe
file_name = "./Endgame.mp3"
# Loads the audio into memory
with io.open(file_name, 'rb') as audio_file:
content = audio_file.read()
audio = types.RecognitionAudio(content=content)
config = types.RecognitionConfig(
encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=16000,
language_code='en-US',
enableWordTimeOffsets=True)
# Detects speech in the audio file
response = client.LongRunningRecognize(config, audio)
for result in response.results:
print('Transcript: {}'.format(result.alternatives[0].transcript))body = {
"requests": [
{
"image": {
"source": {
"imageUri": "https://www.vet.cornell.edu/sites/default/files/Dog%20running%20in%20field.png"
}
},
"features": [
{
"type": "LABEL_DETECTION",
"maxResults": 1
},
{
"type": "FACE_DETECTION",
"maxResults": 3
}
]
}
]
}
header = "Content-Type: application/json; charset=utf-8"
url = https://vision.googleapis.com/v1/images:annotate?key=[API_KEY]body = {
"input":{
"text":"Android is a mobile operating system developed by Google, based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablets."
},
"voice":{
"languageCode":"en-gb",
"name":"en-GB-Standard-A",
"ssmlGender":"FEMALE"
},
"audioConfig":{
"audioEncoding":"MP3"
}
}
url = https://texttospeech.googleapis.com/v1/text:synthesize?key=[API_KEY]