Update examples and readme#19
Conversation
| api_key = os.environ["BASETEN_API_KEY"] | ||
| mars_url = os.getenv("BASETEN_MARS_URL") or os.getenv("BASETEN_MARS_PRO_URL") | ||
| ref_path = os.getenv("BASETEN_REFERENCE_AUDIO_PATH", "audio.wav") | ||
|
|
||
| client = CambAI( | ||
| tts_provider="baseten", | ||
| provider_params={"api_key": api_key, "mars_url": mars_url}, | ||
| ) |
There was a problem hiding this comment.
can u keep it in global like before? it is like that for a reason -- for more clarity
also client is usually kept global so that same instance can be called by multiple users
| def main() -> None: | ||
| client = CambAI(api_key=os.environ["CAMB_API_KEY"]) | ||
| response = client.dub.create_dub( | ||
| video_url="https://www.youtube.com/...link...", |
There was a problem hiding this comment.
you can keep like before, no need of env
| ) | ||
| task_id = response.task_id | ||
| print(f"Dub Task created with ID: {task_id}") | ||
| assert task_id is not None |
| break | ||
| time.sleep(5) | ||
| info = client.dub.get_dubbed_run_info(status_response.run_id) | ||
| if info.video_url: |
There was a problem hiding this comment.
you can just print it no? worst case, null will be printed
|
|
||
|
|
||
| def main() -> None: | ||
| client = CambAI(api_key=os.environ["CAMB_API_KEY"]) |
|
|
||
| def main() -> None: | ||
| client = CambAI(api_key=os.environ["CAMB_API_KEY"]) | ||
| with open(os.environ["STORY_FILE_PATH"], "rb") as f: |
There was a problem hiding this comment.
You could just create a small "resources subfolder" and add a path to that file.
Also same for title, too much dependency on os.environ, we do not need to store anything in the env
| def test_text_to_audio(): | ||
| # Note: audio_type values are "sound" or "music" | ||
| def main() -> None: | ||
| client = CambAI(api_key=os.environ["CAMB_API_KEY"]) |
| SPEECH_TEXT = ( | ||
| "Good evening. Tonight, the city sleeps under a thin veil of rain, " | ||
| "and every streetlight looks like a small sun trapped in glass. " | ||
| "If you listen closely, you can hear the rhythm of footsteps fading " | ||
| "into the distance—steady, unhurried, almost like a heartbeat. " | ||
| "Somewhere, a clock strikes the hour, and for a moment, everything feels still." | ||
| ) | ||
|
|
||
| VOICE_DESCRIPTION = ( | ||
| "Adult male, late 30s to early 40s, North American accent with a neutral, " | ||
| "broadcast-quality tone. Deep, warm baritone with smooth resonance and clear " | ||
| "diction. Pace is measured and unhurried, with gentle pauses at commas and " | ||
| "a slight lift at the end of reflective sentences. Delivery is calm, intimate, " | ||
| "and slightly wistful—like a late-night radio host reading poetry, not " | ||
| "performing for a crowd. Low breath noise, minimal sibilance, consistent volume, " | ||
| "and a soft, natural smile in the voice without sounding cheerful or salesy." | ||
| ) | ||
|
|
||
|
|
||
| def main() -> None: | ||
| client = CambAI(api_key=os.environ["PROD"]) | ||
| create_out = client.text_to_voice.create_text_to_voice( |
There was a problem hiding this comment.
yeah, the request fails if the description is short. So we're just fast forwarding the process for the user so that they can just run snippet
| status_response = client.dub.get_dubbing_status(task_id=task_id) | ||
| print(f"Current Status: {status_response.status}") | ||
| if status_response.status == "SUCCESS": | ||
| dubbed_run_info = client.dub.get_dubbed_run_info(status_response.run_id) | ||
| print(f"Dubbed Video URL: {dubbed_run_info.audio_url}") | ||
| print(f"Dubbed Video URL: {dubbed_run_info.transcript}") | ||
| print(f"Dubbed Video URL: {dubbed_run_info.video_url}") | ||
| status = client.dub.get_dubbing_status(task_id=task_id) | ||
| if status.status == "SUCCESS": | ||
| info = client.dub.get_dubbed_run_info(status.run_id) | ||
| print(info.video_url or info.audio_url) |
There was a problem hiding this comment.
i dont see a reason for this change..
No description provided.