You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
raiseInvalidWebSocketOptionsError("Provide a WebSocket URI.")
1955
1956
1957
+
defstart_captions(
1958
+
self,
1959
+
session_id: str,
1960
+
opentok_token: str,
1961
+
language_code: str="en-US",
1962
+
max_duration: int=14400,
1963
+
partial_captions: bool=True,
1964
+
status_callback_url: str=None,
1965
+
):
1966
+
"""
1967
+
Starts real-time Live Captions for an OpenTok Session. The maximum allowed duration is 4 hours, after which the audio
1968
+
captioning will stop without any effect on the ongoing OpenTok Session.
1969
+
An event will be posted to your callback URL if provided when starting the captions.
1970
+
1971
+
Each OpenTok Session supports only one audio captioning session. For more information about the Live Captions feature,
1972
+
see the Live Captions developer guide <https://tokbox.com/developer/guides/live-captions/>.
1973
+
1974
+
:param String 'session_id': The OpenTok session ID. The audio from participants publishing into this session will be used to generate the captions.
1975
+
:param String 'opentok_token': A valid OpenTok token with role set to Moderator.
1976
+
:param String 'language_code' Optional: The BCP-47 code for a spoken language used on this call.
1977
+
:param Integer 'max_duration' Optional: The maximum duration for the audio captioning, in seconds.
1978
+
:param Boolean 'partial_captions' Optional: Whether to enable this to faster captioning at the cost of some inaccuracies.
1979
+
:param String 'status_callback_url' Optional: A publicly reachable URL controlled by the customer and capable of generating the content to be rendered without user intervention. The minimum length of the URL is 15 characters and the maximum length is 2048 characters.
1980
+
"""
1981
+
1982
+
payload= {
1983
+
"sessionId": session_id,
1984
+
"token": opentok_token,
1985
+
"languageCode": language_code,
1986
+
"maxDuration": max_duration,
1987
+
"partialCaptions": partial_captions,
1988
+
"statusCallbackUrl": status_callback_url,
1989
+
}
1990
+
1991
+
logger.debug(
1992
+
"POST to %r with params %r, headers %r, proxies %r",
1993
+
self.endpoints.get_captions_url(),
1994
+
json.dumps(payload),
1995
+
self.get_json_headers(),
1996
+
self.proxies,
1997
+
)
1998
+
1999
+
response=requests.post(
2000
+
self.endpoints.get_captions_url(),
2001
+
json=payload,
2002
+
headers=self.get_json_headers(),
2003
+
proxies=self.proxies,
2004
+
timeout=self.timeout,
2005
+
)
2006
+
2007
+
ifresponseandresponse.status_code==200:
2008
+
returnCaptions(response.json())
2009
+
elifresponse.status_code==400:
2010
+
"""
2011
+
The HTTP response has a 400 status code in the following cases:
2012
+
You did not pass in a session ID or you passed in an invalid session ID.
2013
+
You specified an invalid value for input parameters.
2014
+
"""
2015
+
raiseRequestError(response.json().get("message"))
2016
+
elifresponse.status_code==403:
2017
+
raiseAuthError("You passed in an invalid OpenTok API key or JWT.")
2018
+
elifresponse.status_code==409:
2019
+
raiseCaptioningAlreadyInProgressError(
2020
+
"Live captions have already started for this OpenTok Session."
0 commit comments