Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codenamewei/youtube2text
Converts Youtube URLs to Text with Speech Recognition
https://github.com/codenamewei/youtube2text
Last synced: 3 months ago
JSON representation
Converts Youtube URLs to Text with Speech Recognition
- Host: GitHub
- URL: https://github.com/codenamewei/youtube2text
- Owner: codenamewei
- License: mit
- Created: 2022-01-01T07:10:16.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-18T16:33:22.000Z (about 2 years ago)
- Last Synced: 2024-07-24T12:31:03.032Z (4 months ago)
- Language: Python
- Homepage:
- Size: 67.4 KB
- Stars: 23
- Watchers: 3
- Forks: 7
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
## 🔊 Converts Youtube URLs to Text with Speech Recognition
### 💡 What does the library does?
- **Youtube -> Text**: Translate youtube urls as text file (csv)
- **Youtube -> Audio**: Downloads youtube urls as audio file (wav, flac)
- **Audio -> Text**: Translate audio file (wav, flac) to text file (csv)Three folders will be created to store the output files.
```
or /youtube2text
│
├── audio/
│ └── 2022Jan02_011802.flac
|
├── audio-chunks/
│ └── 2022Jan02_011802
│ ├── chunk1.flac
│ ├── chunk2.flac
│ └── chunk3.flac
│
└── text/
└── 2022Jan02_011802.csv
```### :package: How to install
Install and update using [pip](https://pypi.org/project/youtube2text/)
```
pip install youtube2text
```### 🔧Build from source
```
git clone
cd
python setup.py install
```### ✨ How to use
- Using the library requires **internet connection** for both downloading youtube videos and speech recognition operation
```
from youtube2text import Youtube2Textconverter = Youtube2Text()
converter.url2text(urlpath="https://www.youtube.com/watch?v=Ad9Q8rM0Am0&t=114s")
```Check out more at [howtouse.ipynb](tests/howtouse.ipynb)
### 📌 Functions
- Support audio output of
- wav
- flac
- Support Automatic Speech Recognition with [speech-recognition library](https://pypi.org/project/SpeechRecognition/)#### Youtube -> Text
```
def url2text(self, urlpath, outfile = None, audioformat = "flac", audiosamplingrate=16000):
'''
Convert youtube url to textParameters:
urlpath (str): Youtube url
outfile (str, optional): File path/name of output file (.csv)
audioformat (str, optional): Audioformat supported in self.__audioextension
audiosamplingrate (int, optional): Audio sampling rate
'''
```#### Youtube -> Audio
```
def url2audio(self, urlpath, audiofile = None, audiosamplingrate=16000):
'''
Convert youtube url to audiofileParameters:
urlpath (str): Youtube url
audiofile (str, optional): File path/name to save audio file
audiosamplingrate (int, optional): Audio sampling rate
'''
```#### Audio -> Text
```
def audio2text(self, audiofile, textfile = None):
'''
Convert audio to csv fileParameters:
audiofile (str): File path/name of audio file
textfile (str, optional): File path/name of text file (*.csv)
'''
```
## 🚨 Note
- This repository is highly dependent on [Pytube](https://github.com/pytube/pytube) to download Youtube videos, which at times buggy. Workaround is often provided in issues page of [Pytube repository](https://github.com/pytube/pytube/issues) or [in this repository](https://github.com/codenamewei/youtube2text/issues). Do take the intiative to file for issues to help others who will use this repository.## 📝 Article
Read out the article below on how to use the repository.
- [Youtube to Text with Speech Recognition in Python](https://towardsdatascience.com/youtube-to-text-with-speech-recognition-in-python-cd47d6d98b16?sk=be41e705c8b182795712a70419a5b8d0)
## 📩 Reach out to me
This repository is created out from personal use to retrieve audio files for conversational speech recognition and audio classification.
For custom functionality development support, enterprise support and other related questions, reach out at