Skip to content

Instantly share code, notes, and snippets.

View AIAnytime's full-sized avatar
👋
On vacation

AI Anytime AIAnytime

👋
On vacation
View GitHub Profile
@AIAnytime
AIAnytime / stereo_to_mono
Last active July 17, 2022 04:08
Python provides a pydub module that enables you to play, split, merge, and edit WAV audio files. This is how you can use it to convert a stereo WAV file to a mono file.
from pydub import AudioSegment
mysound = AudioSegment.from_wav("stereo_infile.wav")
# set mono channel
mysound = mysound.set_channels(1)
# save the result
mysound.export("mono_outfile.wav", format="wav") It was originally published on https://www.apriorit.com/
@AIAnytime
AIAnytime / ubuntu_run
Last active July 17, 2022 03:37
This file contains instruction to start with Anaconda in Ubuntu.
## How to activate anaconda from terminal?
1. open terminal and write:
```
conda activate
```
It will show base activated succesfully.
## How to deactivate anaconda from terminal?
```
conda deactivate
@AIAnytime
AIAnytime / disable_gpu.py
Created February 23, 2021 09:03
How to disable GPU with TensorFlow?
try:
# Disable all GPUS
tf.config.set_visible_devices([], 'GPU')
visible_devices = tf.config.get_visible_devices()
for device in visible_devices:
assert device.device_type != 'GPU'
except:
# Invalid device or cannot modify virtual devices once initialized.
pass
@AIAnytime
AIAnytime / gpu_memory_save.py
Created February 19, 2021 06:06
Few snippets to work with GPU memory management while working with Keras
#1st snippet
from keras import backend as K
cfg = K.tf.ConfigProto()
cfg.gpu_options.allow_growth = True
K.set_session(K.tf.Session(config=cfg))
#2nd snippet
def limit_mem():
K.get_session().close()
cfg = K.tf.ConfigProto()
@AIAnytime
AIAnytime / pdftext_to_speech.py
Last active February 19, 2021 06:07
Convert PDF File text to audio speech using Python
import pyttsx3
import PyPDF2
path = open('resume.pdf', 'rb')
pdf_reader = PyPDF2.PdfFileReader(path)
from_page = pdfReader.getPage(0)
text = from_page.extractText()
speak = pyttsx3.init()
speak.say(text)