-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
308 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
"""Copyright 2019 REV | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
""" | ||
|
||
import time | ||
from rev_ai import apiclient, JobStatus | ||
from rev_ai.models.asynchronous.summarization_job_status import SummarizationJobStatus | ||
from rev_ai.models.asynchronous.summarization_options import SummarizationOptions | ||
from rev_ai.models.nlp_model import NlpModel | ||
|
||
# String containing your access token | ||
access_token = "<your_access_token>" | ||
|
||
# Create your api client | ||
client = apiclient.RevAiAPIClient(access_token) | ||
|
||
# Submitting a job through a local file. | ||
# | ||
# job = client.submit_job_local_file("your_local_file_path", | ||
# delete_after_seconds=2592000, | ||
# language='en', | ||
# summarization_config=SummarizationOptions( | ||
# model=NlpModel.PREMIUM | ||
# )) | ||
|
||
|
||
# Submitting a job with a link to the file you want transcribed | ||
# Change url to your url, custom_vocabularies is optional like above | ||
url = "https://www.rev.ai/FTC_Sample_1.mp3" | ||
job = client.submit_job_url(media_url=url, | ||
delete_after_seconds=2592000, | ||
language='en', | ||
summarization_config=SummarizationOptions(model=NlpModel.PREMIUM)) | ||
|
||
print("Submitted Job") | ||
print("Job Status : {}".format(job.status)) | ||
# Checks if the job has been transcribed and summarized. Please note that this is not the recommended way | ||
# of getting job status in a real application. For recommended methods of getting job status | ||
# please see our documentation on setting a callback url here: | ||
# https://docs.rev.ai/resources/tutorials/get-started-api-webhooks/ | ||
|
||
while job.status == JobStatus.IN_PROGRESS: | ||
time.sleep(5) | ||
# Obtains details of a job in json format | ||
job = client.get_job_details(job.id) | ||
print("Job Status : {}".format(job.status)) | ||
|
||
if job.status == JobStatus.FAILED: | ||
print("Job Failed : {}".format(job.failure_detail)) | ||
exit() | ||
|
||
if job.status == JobStatus.TRANSCRIBED: | ||
print("Summarization Status : {}".format(job.summarization.status)) | ||
# Checks if the job has been summarized. Please note that this is not the recommended way | ||
# of getting job status in a real application. For recommended methods of getting job status | ||
# please see our documentation on setting a callback url here: | ||
# https://docs.rev.ai/resources/tutorials/get-started-api-webhooks/ | ||
while job.summarization.status == SummarizationJobStatus.IN_PROGRESS: | ||
time.sleep(5) | ||
# Obtains details of a job in json format | ||
job = client.get_job_details(job.id) | ||
print("Summarization Status : {}".format(job.summarization.status)) | ||
|
||
if job.summarization.status == SummarizationJobStatus.FAILED: | ||
print("Summarization Failed : {}".format(job.summarization.failure)) | ||
exit() | ||
|
||
# obtain transcript summary as a string for the job. | ||
summary_text = client.get_transcript_summary_text(job.id) | ||
print(summary_text) | ||
|
||
# obtain transcript summary as a json object for the job. | ||
summary_json = client.get_transcript_summary_json(job.id) | ||
|
||
# obtain transcript summary object for the job. | ||
summary_obj = client.get_transcript_summary_object(job.id) | ||
|
||
# Use the objects however you please | ||
|
||
# Once you are done with the job, you can delete it. | ||
# NOTE : This will PERMANENTLY DELETE all data related to a job. Exercise only | ||
# if you're sure you want to delete the job. | ||
# client.delete_job(job.id) | ||
print("Job Submission and Collection Finished.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
"""Copyright 2019 REV | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
""" | ||
|
||
import time | ||
from rev_ai import apiclient, JobStatus | ||
from rev_ai.models.asynchronous.translation_job_status import TranslationJobStatus | ||
from rev_ai.models.asynchronous.translation_language_options import TranslationLanguageOptions | ||
from rev_ai.models.asynchronous.translation_options import TranslationOptions | ||
from rev_ai.models.nlp_model import NlpModel | ||
|
||
# String containing your access token | ||
access_token = "<your_access_token>" | ||
|
||
# Create your api client | ||
client = apiclient.RevAiAPIClient(access_token) | ||
|
||
# Submitting a job through a local file. | ||
# | ||
# job = client.submit_job_local_file("your_local_file_path", | ||
# delete_after_seconds=2592000, | ||
# language='en', | ||
# translation_config=TranslationOptions( | ||
# target_languages=[ | ||
# TranslationLanguageOptions("es", NlpModel.PREMIUM) | ||
# ] | ||
# )) | ||
|
||
|
||
# Submitting a job with a link to the file you want transcribed and translated | ||
url = "https://www.rev.ai/FTC_Sample_1.mp3" | ||
job = client.submit_job_url(media_url=url, | ||
delete_after_seconds=2592000, | ||
language='en', | ||
translation_config=TranslationOptions( | ||
target_languages=[ | ||
TranslationLanguageOptions("es", NlpModel.PREMIUM) | ||
] | ||
)) | ||
|
||
print("Submitted Job") | ||
print("Job Status : {}".format(job.status)) | ||
|
||
# Checks if the job has been transcribed and summarized. Please note that this is not the recommended way | ||
# of getting job status in a real application. For recommended methods of getting job status | ||
# please see our documentation on setting a callback url here: | ||
# https://docs.rev.ai/resources/tutorials/get-started-api-webhooks/ | ||
|
||
while job.status == JobStatus.IN_PROGRESS: | ||
time.sleep(5) | ||
# Obtains details of a job in json format | ||
job = client.get_job_details(job.id) | ||
print("Job Status : {}".format(job.status)) | ||
|
||
if job.status == JobStatus.FAILED: | ||
print("Job Failed : {}".format(job.failure_detail)) | ||
exit() | ||
|
||
if job.status == JobStatus.TRANSCRIBED: | ||
print("Translation Status : {}".format(job.translation.target_languages[0].status)) | ||
# Checks if the job has been summarized. Please note that this is not the recommended way | ||
# of getting job status in a real application. For recommended methods of getting job status | ||
# please see our documentation on setting a callback url here: | ||
# https://docs.rev.ai/resources/tutorials/get-started-api-webhooks/ | ||
while job.translation.target_languages[0].status == TranslationJobStatus.IN_PROGRESS: | ||
time.sleep(5) | ||
# Obtains details of a job in json format | ||
job = client.get_job_details(job.id) | ||
print("Translation Status : {}".format(job.translation.target_languages[0].status)) | ||
|
||
if job.translation.target_languages[0].status == TranslationJobStatus.FAILED: | ||
print("Translation Failed : {}".format(job.translation.target_languages[0].failure)) | ||
exit() | ||
|
||
# obtain transcript translation as a string for the job. | ||
transcript_text = client.get_translated_transcript_text(job.id, 'es') | ||
print(transcript_text) | ||
|
||
# obtain transcript translation as a json object for the job. | ||
transcript_json = client.get_translated_transcript_json(job.id, 'es') | ||
|
||
# obtain transcript translation object for the job. | ||
transcript_obj = client.get_translated_transcript_object(job.id, 'es') | ||
|
||
# obtain translated captions for the job. | ||
captions = client.get_translated_captions(job.id, 'es') | ||
|
||
# Use the objects however you please | ||
|
||
# Once you are done with the job, you can delete it. | ||
# NOTE : This will PERMANENTLY DELETE all data related to a job. Exercise only | ||
# if you're sure you want to delete the job. | ||
# client.delete_job(job.id) | ||
print("Job Submission and Collection Finished.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
rev-ai==2.17.1 | ||
rev-ai==2.19.1 | ||
pyaudio==0.2.11 | ||
six==1.12.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.