-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain-insecure.py
26 lines (20 loc) · 1.04 KB
/
main-insecure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
import grpc
from stub.speech_recognition_open_api_pb2_grpc import SpeechRecognizerStub
from main import read_audio, transcribe_url, transcribe_audio_bytes
if __name__ == '__main__':
host = "<ip to grpc>"
port = 50051
with grpc.insecure_channel('{}:{}'.format(host, port)) as channel:
stub = SpeechRecognizerStub(channel)
language = 'hi'
audio_url = 'https://storage.googleapis.com/test_public_bucket/download.mp3'
response = transcribe_url(stub, audio_url, language, 'mp3', 'transcript')
print(response.output[0].source)
response = transcribe_url(stub, audio_url, language, 'mp3', 'srt')
print(response.output[0].source)
audio_bytes = read_audio('changed.wav')
response = transcribe_audio_bytes(stub, audio_bytes, language, 'wav', 'transcript')
print('Response from Audio bytes:'+response.output[0].source)
response = transcribe_audio_bytes(stub, audio_bytes, language, 'wav', 'srt')
print('Response from Audio bytes:'+response.output[0].source)