V‑Cloud Scripts
V-Cloud Python Script
The following is a simple python script that submits an audio file for transcription and retrieves the results. Replace the generic token
and filename
values with a valid authorization token and an audio file to transcribe. Additional transcription parameters can be defined as values of the data
variable. The syntax for transcription parameters is 'parameter-name': 'parameter-value'
. Refer to V‑Cloud Transcription Parameters for more information.
import requests token = "yourTokenHere" filename = "yourAudioHere" response = requests.post( "https://vcloud.vocitec.com/transcribe", data={"token": token, "output": "text"}, files=[("file", (filename, open(filename,"rb"), "audio/x-wav"))] ) response.raise_for_status() requestid = response.json()["requestid"] response = None while not response or response.status_code != 200: response = requests.get( f"https://vcloud.vocitec.com/transcribe/result/{requestid}", params={"token": token} ) response.raise_for_status() print(response.text)
V-Cloud Bash Script
The following is a simple bash script that prompts to collect the information required for a transcription request. Once the information is provided, the script submits the specified audio file for transcription and prints the results to a file.
#!/bin/bash if [ -z $1 ] then echo "Please supply a valid authorization token for V-Cloud." exit 1 fi TOKEN=$1 if [ -z $2 ] then echo "Please supply the input name of WAV file." exit 1 fi INPUT_FILE=$2 if [ -z $3 ] then echo "Please supply the output name of your file." exit 1 fi OUTPUT_FILE=$3 REQUEST_ID=`curl -s -F token=${TOKEN} -F "file=@${INPUT_FILE};type=audio/x-wav" https://vcloud.vocitec.com/transcribe` REQUEST_ID=${REQUEST_ID#*:} REQUEST_ID=${REQUEST_ID:1} REQUEST_ID=${REQUEST_ID::-2} RESULT=`curl -s "https://vcloud.vocitec.com/transcribe/result?token=${TOKEN}&requestid=${REQUEST_ID}"` while [ "${RESULT}" == "No result currently available" ] do sleep 1s RESULT=`curl -s "https://vcloud.vocitec.com/transcribe/result?token=${TOKEN}&requestid=${REQUEST_ID}"` done RESULT=${RESULT:1} RESULT=${RESULT::-1} curl -s "${RESULT}" > "${OUTPUT_FILE}"