How To Check Character Count For Google Translation API?
I am using the following code to translate using the google translation API from google.cloud import translate_v2 as translate translate_client = translate.Client(credentials=cred
Solution 1:
Even I do not think there is a direct way of requesting such information (apart from the console), there is a way of creating alerting policies internally.
You can set an alerting policy that is triggered for a certain number of requested bytes and apply 1 char = 8 bit = 1 byte.
In order to do that, you should go Monitoring -> Alerting -> Create New Policy ->
·Resource type: Consumed API
·Metric: Request sizes
·Filter -> Service = translate.googleapis.com
and configure as much triggers as you like. I hope this finds well!
Solution 2:
Try storing the value in a file? Every time you translate n
characters,
- read the
count
from file - increment
count
byn
- write
count
back to the file
Post a Comment for "How To Check Character Count For Google Translation API?"