|
13 | 13 | import os |
14 | 14 | import time |
15 | 15 | import warnings |
| 16 | +import json |
16 | 17 | # Constants for API operations |
17 | 18 | TIMEOUT = 60 |
18 | 19 | POLL_INTERVAL = 5 |
@@ -68,8 +69,10 @@ def __init__(self, api_client=None, api_key: Optional[str] = None) -> None: |
68 | 69 | configuration = Configuration() |
69 | 70 | if api_key: |
70 | 71 | configuration.api_key['APIKeyHeader'] = api_key |
71 | | - else: |
| 72 | + elif os.environ.get("CAMB_API_KEY"): |
72 | 73 | configuration.api_key['APIKeyHeader'] = os.environ.get("CAMB_API_KEY") |
| 74 | + else: |
| 75 | + raise ValueError("API key not provided. Please provide api_key or set CAMB_API_KEY environment variable.") |
73 | 76 | api_client = ApiClient(configuration=configuration) |
74 | 77 | self.api_client = api_client |
75 | 78 |
|
@@ -437,7 +440,6 @@ def end_to_end_dubbing( |
437 | 440 | if verbose: |
438 | 441 | print(f"Processing complete! Run ID: {result.run_id}") |
439 | 442 | print("Retrieving dubbing result...") |
440 | | - |
441 | 443 | response = self.get_dubbed_run_info_by_id(result.run_id) |
442 | 444 | return response |
443 | 445 |
|
@@ -5087,10 +5089,14 @@ def get_dubbed_run_info_by_id( |
5087 | 5089 | _request_timeout=_request_timeout |
5088 | 5090 | ) |
5089 | 5091 | response_data.read() |
5090 | | - return self.api_client.response_deserialize( |
5091 | | - response_data=response_data, |
5092 | | - response_types_map=_response_types_map, |
5093 | | - ).data |
| 5092 | + raw_data = json.loads(response_data.data.decode('utf-8')) |
| 5093 | + |
| 5094 | + from cambai.models.run_info_response import RunInfoResponse |
| 5095 | + return RunInfoResponse( |
| 5096 | + output_video_url=raw_data.get('video_url'), |
| 5097 | + output_audio_url=raw_data.get('audio_url'), |
| 5098 | + transcript=raw_data.get('transcript') |
| 5099 | + ) |
5094 | 5100 |
|
5095 | 5101 |
|
5096 | 5102 | @validate_call |
|
0 commit comments