OBS-captions-plugin icon indicating copy to clipboard operation
OBS-captions-plugin copied to clipboard

Ability to assign your own API Key

Open Gorexxar opened this issue 10 months ago • 5 comments

The closed captioning tool works ~50% of the time. Is it being rate limited by Google?

If the project is still alive, is it possible to use our own API Key to send to Google?

Gorexxar avatar Apr 01 '24 09:04 Gorexxar

I see it's an environment variable for the api key.

danrossi avatar Apr 29 '24 20:04 danrossi

Ah, you're right. If I'm reading it right, if you build without an accessible API key, it will include a UI for a User Provided Key. Interesting, thanks for the hint.

I'm not overly experienced with C but if I understand it right, we could fork and just force return the custom API Key argument.

https://github.com/ratwithacompiler/OBS-captions-plugin/blob/master/CI/win_shared.py

Gorexxar avatar Apr 29 '24 21:04 Gorexxar

Is there a UI ? I just spotted an environment variable. I'll test it out soon. I'm helping a client trying to set it up for testing as the default key has a time restriction. It worked so well however showing up in HLS via wowza. And over some latency too from my location subscribing to it. It seems the google api is incredibly expensive but there is a batch feature to not stream partial words back but buffer it. 0.18 cents an hour batching compared to 0.96 cents an hour. Need to test if that works for live and kept in sync or not.

danrossi avatar Apr 30 '24 07:04 danrossi

Ah, you're right. If I'm reading it right, if you build without an accessible API key, it will include a UI for a User Provided Key. Interesting, thanks for the hint.

I'm not overly experienced with C but if I understand it right, we could fork and just force return the custom API Key argument.

https://github.com/ratwithacompiler/OBS-captions-plugin/blob/master/CI/win_shared.py

How do you build to be able to use your own key? Is it just looking for a set GOOGLE_API_KEY env var during the build?

UPDATE: I managed to figure this out based on the pipelines file in this repo.

First, make sure you have GCP ready:

  1. Sign up for GCP
  2. Create a billing profile
  3. Create a project
  4. Enable the Cloud Speech-to-Text API
  5. In Credentials, create an API Key

Now to build a new libobs_google_caption_plugin.so, I used Docker: docker run -it -v /home/someuser/Downloads/docker-build/vol:/opt ubuntu:22.04 bash

Once inside the container, I ran the following commands:

apt-get update
apt-get install git wget build-essential cmake sudo zip curl unzip tar -y
cd /opt
git clone https://github.com/ratwithacompiler/OBS-captions-plugin.git
export GOOGLE_API_KEY=<YOUR API KEY>
export CLEAN_OBS=1
export CLEAN_VCPKG=1
cd OBS-captions-plugin/CI/http/
./linux_install_script.sh 
cd ../grpc/
./linux_install_script.sh

Then I opened a new shell and copied the generated file as follows:

cp /home/someuser/Downloads/docker-build/vol/OBS-captions-plugin/CI/grpc/CI_build/release/Closed_Captions_Plugin__v0.30_Linux/libobs_google_caption_plugin/bin/64bit/libobs_google_caption_plugin.so ~/.config/obs-studio/plugins/libobs_google_caption_plugin/bin/64bit

I verified the API key was in use by going to GCP and seeing the API activity.

Hope this helps!

norus avatar Aug 18 '24 20:08 norus