Hi All,
I am using python sample code for batch transcription but I'm facing issues when trying to implement the Speech Services Batch Transcription API using Python. It would be really great if you can help us on this case.
Code:
speech-to-text.txt
Error:
AttributeError Traceback (most recent call last)
in
200
201 if name == "main":
--> 202 transcribe()
in transcribe()
139 print(client)
140 # create an instance of the transcription api class
--> 141 api = cris_client.DefaultApi(api_client=client)
142
143 # Specify transcription properties by passing a dict to the properties parameter. See
AttributeError: module 'swagger_client' has no attribute 'DefaultApi'
Note: Installed swagger_client successfully
Please make sure you have the latest version of the swagger_client (for API v3) installed. The version used with a previous version of the sample (v2 API) is not compatible.
Hi @chlandsi ,
Thanks for the prompt response!
If possible, could you please share the reference/steps for installing swagger_client (for API v3) using python
Many thanks in advance!
Hi @vishnureddy45, please run pip uninstall swagger_client in the Python environment where you installed it, and then follow the steps in the sample.
Hi @chlandsi ,
I have used the below Swagger URL for the Speech Services API generation and installed swagger_client without any issues but i am facing issues while running the main.py
Case1 Error:
SERVICE_REGION = "eastus"
ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Cache-Control': 'no-cache', 'Pragma': 'no-cache', 'Content-Length': '329', 'Content-Type': 'text/plain; charset=utf-8', 'Expires': '-1', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'apim-request-id': '6b4e4868-c181-44ae-b99e-7db43be56d20', 'Date': 'Tue, 08 Dec 2020 10:13:39 GMT'})
HTTP response body: {"code":"InvalidRequest","details":null,"message":"Only "Standard" subscriptions for the region of the called service are valid.","target":null,"innerError":{"code":"InvalidSubscription","details":null,"message":"Only "Standard" subscriptions for the region of the called service are valid.","target":null,"innerError":null}}
Case 2 Error:
SERVICE_REGION = "east-us"
MaxRetryError: HTTPSConnectionPool(host='east-us.api.cognitive.microsoft.com', port=443): Max retries exceeded with url: /speechtotext/v3.0/transcriptions (Caused by NewConnectionError('
Kindly help me out from this issue.
Hi @vishnureddy45, please use "eastus" as the region name (without hyphen).
You can find all region names here.
Hi @chlandsi ,
when i used eastus facing the below error
SERVICE_REGION = "eastus"
ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Cache-Control': 'no-cache', 'Pragma': 'no-cache', 'Content-Length': '329', 'Content-Type': 'text/plain; charset=utf-8', 'Expires': '-1', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'apim-request-id': '6b4e4868-c181-44ae-b99e-7db43be56d20', 'Date': 'Tue, 08 Dec 2020 10:13:39 GMT'})
HTTP response body: {"code":"InvalidRequest","details":null,"message":"Only "Standard" subscriptions for the region of the called service are valid.","target":null,"innerError":{"code":"InvalidSubscription","details":null,"message":"Only "Standard" subscriptions for the region of the called service are valid.","target":null,"innerError":null}}
It looks like you are using a free Speech Service subscription (F0 tier). The batch transcription service can only be used with a standard, paid subscription (S0 tier).
let me check on the subscription. In case, if issue remains same will get back to you.
Thanks a lot for quick help christian @chlandsi .
Hi @chlandsi ,
You're right! Previously I was using free Speech Service subscription (F0 tier).
After upgrading to standard subscription facing the below error and also please find the code attached.
Container: vishnu
Folder: vishnu-speech
Filename: sample_conversation
12/08/2020 03:36:16 PM Coordinated Universal Time Starting transcription client...
{'_self': None,
'content_container_url': None,
'content_urls': ['https://vishnu.blob.core.windows.net/vishnu-speech/sample_conversation.wav'],
'created_date_time': None,
'custom_properties': None,
'dataset': None,
'description': 'Simple transcription description',
'display_name': 'Simple transcription',
'last_action_date_time': None,
'links': None,
'locale': 'en-US',
'model': None,
'project': None,
'properties': {},
'status': None}
12/08/2020 03:36:17 PM Coordinated Universal Time Created new transcription with id '0f1ba4-bcf6-5839ff6996a8' in region eastus
12/08/2020 03:36:17 PM Coordinated Universal Time Checking status.
12/08/2020 03:36:22 PM Coordinated Universal Time Transcriptions status: Failed
12/08/2020 03:36:22 PM Coordinated Universal Time Transcription failed: The recordings URI is invalid.
This means that the file cannot be accessed. It seems the file is not available at that address (I can't download it either). Please make sure to pass a uri with correct authorization, either by making it publicly accessible or by passing a (currently valid) SAS Uri.
Hi @chlandsi,
we have successfully implemented batch subscription API[standard paid subscription (S0 tier)] , could able to see the transcribed text with the speakers(channel 0 and 1) but we鈥檙e unable to identify the start_time and end_time of speakers. Kindly help us on the same.
Note: Able to identify start_time and end_time using AWS Transcribe.
Hi @vishnureddy45, good to hear that there is progress! It sounds like you are looking for what we call the diarization feature. You can enable it by passing the flag diarizationEnabled: true with the request (docs).
Timing information is exposed in the offset and duration fields of the recognizedPhrases list in the results.
Hi @chlandsi,
We could see offset and duration in the output but we're not sure how to fetch start_time and end_time of the recognized phrases. Kindly help us on this case.
Hi @vishnureddy45, not sure if I understand correctly - offset is the start time of the utterance (with respect to the beginning of the file), and offset + duration should give you the end time of each utterance. Does that serve your purpose?
Thanks @chlandsi .
Let me try the provided suggestion and I'll get back to you
Closing the issue as resolved since no updates since December, please open a new item if you need further support.