**Using Assembly AI to Generate Time Stamps from YouTube Videos**
In this tutorial, we will explore how to use Assembly AI to generate time stamps from YouTube videos. We will start by creating an API key and setting it up as a secret in our code.
Once we have our API key, we can create a new secret called "AI Key" and paste the value into our code. This will allow us to use Assembly AI's functionality to generate time stamps.
To import the necessary code, we will need to add the following block of code:
```python
from assemblyai import Transcriber
# Set up Assembly AI API key
assembly_ai_key = "YOUR_API_KEY_HERE"
# Create a new secret called 'AI Key'
secret = {
"name": "AI Key",
"value": assembly_ai_key,
}
# Import the necessary code
import assemblyai as ai
```
**Transcribing Audio and Generating Transcript**
First, we need to transcribe our audio file using Assembly AI's `transcriber` function. We will save the transcript in a variable called `transcript`.
Here is an example of how to do this:
```python
# Transcribe the audio file using Assembly AI's transcriber function
transcriber = ai.Transcriber()
audio_file = "path/to/audio/file.mp3"
transcript = transcriber.transcribe(audio_file)
```
**Combining Transcript into a Corpus Text**
Next, we need to combine our transcript into a single corpus text. We will store this in a variable called `paragraphs`.
Here is an example of how to do this:
```python
# Combine the transcript into a single corpus text
corpus_text = ""
for sentence in transcript.split("."):
corpus_text += sentence + " "
```
**Generating Time Stamps**
Now that we have our corpus text, we can start generating time stamps for each paragraph. We will use a loop to iterate through each paragraph and generate key topics.
Here is an example of how to do this:
```python
# Generate time stamps for each paragraph
time_stamps = []
for i in range(0, len(paragraphs), 5):
paragraph = paragraphs[i:i+5]
for j in range(len(paragraph)):
topic = ai.TopicGenerator().generate_topic(paragraph[j])
start_time = ai.TimeStamp.generate_start_time(j*60) # assuming each minute has 60 seconds
end_time = ai.TimeStamp.generate_end_time(start_time, len(paragraph[j]))
time_stamps.append((start_time, end_time, topic))
```
**Running the Script**
Once we have generated our time stamps, we can run the script to see the results.
The final output will be a list of time stamps with corresponding key topics. The time stamps will be in the format `MM:SS`, and the key topics will be based on the transcription of each paragraph.
**Example Output**
Here is an example of what the output might look like:
```
[("00:13:14", "01:14:15"), ("01:16:05", "02:17:06")]
[( "00:10:35", "Trust Your Intuition"), ("01:11:20", "Perseverance") ]
...
```
Note that the actual output will depend on the transcription of your audio file and the topic generator's ability to identify key topics.
**Conclusion**
In this tutorial, we used Assembly AI to generate time stamps from a YouTube video. We transcribed the audio file using Assembly AI's `transcriber` function, combined the transcript into a single corpus text, and generated time stamps for each paragraph using a loop. The final output was a list of time stamps with corresponding key topics.
We hope this tutorial helps you understand how to use Assembly AI to generate time stamps from YouTube videos. If you have any questions or need further assistance, please don't hesitate to ask.