Daniel Amendoeira commited on
Commit
2105776
·
verified ·
1 Parent(s): 1004e6c

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +8 -12
tools.py CHANGED
@@ -36,11 +36,10 @@ datetime_tools = [current_date, day_of_week, days_until]
36
  @tool
37
  def transcribe_audio(audio_file: str, file_extension: str) -> str:
38
  """ Transcribes an audio file to text
39
-
40
  Args:
41
  audio_file (str): local file path to the audio file (.mp3, .m4a, etc.)
42
  file_extension (str): file extension of the audio, e.g. mp3
43
-
44
  Returns:
45
  str: The transcribed text from the audio.
46
  """
@@ -71,21 +70,18 @@ def transcribe_audio(audio_file: str, file_extension: str) -> str:
71
 
72
  # TESTTTTT
73
  @tool
74
- def transcribe_youtube(page_url: str) -> str:
75
- """Get the transcript of a YouTube video
76
  Args:
77
- page_url (str): YouTube URL of the video
78
  """
79
  try:
80
- # get video ID from URL
81
- video_id = extract.video_id(page_url)
82
-
83
- # get transcript
84
- ytt_api = YouTubeTranscriptApi()
85
- transcript = ytt_api.fetch(video_id)
86
 
87
  # keep only text
88
  txt = '\n'.join([s.text for s in transcript.snippets])
89
  return txt
90
  except Exception as e:
91
- return f"get_youtube_transcript failed: {e}"
 
36
  @tool
37
  def transcribe_audio(audio_file: str, file_extension: str) -> str:
38
  """ Transcribes an audio file to text
 
39
  Args:
40
  audio_file (str): local file path to the audio file (.mp3, .m4a, etc.)
41
  file_extension (str): file extension of the audio, e.g. mp3
42
+
43
  Returns:
44
  str: The transcribed text from the audio.
45
  """
 
70
 
71
  # TESTTTTT
72
  @tool
73
+ def transcribe_youtube(youtube_url: str) -> str:
74
+ """ Transcribes a YouTube video
75
  Args:
76
+ youtube_url (str): youtube video's url
77
  """
78
  try:
79
+ video_id = extract.video_id(youtube_url)
80
+ youtube_api = YouTubeTranscriptApi()
81
+ transcript = youtube_api.fetch(video_id)
 
 
 
82
 
83
  # keep only text
84
  txt = '\n'.join([s.text for s in transcript.snippets])
85
  return txt
86
  except Exception as e:
87
+ return f"transcribe_youtube failed: {e}"