Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- import os
- url = "https://stream.watsonplatform.net/speech-to-text-beta/api/v1/recognize"
- username= "USERNAME"
- password= "PASSWORD"
- filepath = '/home/user/myfamily.ogg' # path to file
- filename = os.path.basename(filepath)
- audio = open(filepath,'rb')
- files_input = {
- "audioFile":(filename,audio,'audio/ogg')
- }
- response = requests.post(url, auth=(username, password), headers={"Content-Type": "audio/wav"},files=files_input)
- print('stauts_code: {} (reason: {})'.format(response.status_code, response.reason))
- print response.text
- {
- "error": "Your browser approached me (at /text-to-speech/api) with the method "POST". I only allow the methods HEAD, GET here.",
- "code": 405,
- "code_description": "Method Not Allowed"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement