I'm trying to upload a .wav
file (lets say test.wav
) into my google storage bucket but i'm running into some problems: A storage object gets uploaded with the appropriate 'test.wav' name, but inside it is just the data from my request. Also the contentType
in the bucket is displayed as application/x-www-form-urlencoded
.
My bucket has public read/write/delete permissions and uploading other file types works fine. Uploading this way also works fine through postman.
url = "https://www.googleapis.com/upload/storage/v1/b/<bucket_name>/o"
payload ={
"acl":"public-read",
"file":open('test.wav'),
"signature":signature,
"policy":policy
}
headers={"contentType":"audio/wav"}
params={"uploadType":"media","name":"test.wav"}
response = requests.post(url,data=payload,headers=headers,params=params)
print(response.text)
Currently I get the following error :
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position
4420: character maps to <undefined>
I've also tried scipy.io.wavfile.read()
and pydub.AudioSegment()
but these don't work for me either.
Ideally, I'd want the file to be successfully uploaded and usable for transcription through google's STT.
Thanks and regards.