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 / stt.py
Created May 14, 2023 10:29
Speech to Text Assembly AI
# Assembly AI speech to text
def assemblyai_stt(audio_filename):
with open(audio_filename , "rb") as f:
response = requests.post(base_url + "/upload",
headers=headers,
data=f)
upload_url = response.json()["upload_url"]
data = {
"audio_url": upload_url
@AIAnytime
AIAnytime / pytube_audio.py
Created May 14, 2023 10:29
PyTube Audio Snippet
# PyTube function for YouTube video
def save_audio(url):
yt = YouTube(url)
video = yt.streams.filter(only_audio=True).first()
out_file = video.download()
base, ext = os.path.splitext(out_file)
file_name = base + '.mp3'
try:
os.rename(out_file, file_name)
except WindowsError:
@AIAnytime
AIAnytime / colorizer.py
Created April 16, 2023 08:21
Deoldify Images Streamlit
import streamlit as st
import fastai
from deoldify.visualize import *
def image_colorizer(url):
colorizer = get_image_colorizer(artistic=True)
source_url = url
render_factor = 35
watermarked = True
@AIAnytime
AIAnytime / reverse_sd.py
Created April 7, 2023 17:39
reverse_sd
# -*- coding: utf-8 -*-
"""Reverse SD.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1ci11cstH7uM9SPb6q2hb7f-IiZHYvcDq
"""
!pip install clip-interrogator==0.6.0
@AIAnytime
AIAnytime / spacy_streamlit_ner.py
Created February 18, 2023 16:12
Spacy Displacy Streamlit Code
HTML_WRAPPER = """<div style="overflow-x: auto; border: 1px solid #e6e9ef; border-radius: 0.25rem; padding: 1rem">{}</div>"""
@AIAnytime
AIAnytime / text_classifier_api.py
Created February 5, 2023 16:19
Text Classifier Fast API
from fastapi import FastAPI
import pickle
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.naive_bayes import MultinomialNB
app = FastAPI()
# Load the Tfidf and Naive Bayes models
tfidf = pickle.load(open("tf_idf.pkt", "rb"))
@AIAnytime
AIAnytime / Toxicity_classifier.py
Created February 5, 2023 13:33
Toxicity Classifier
# -*- coding: utf-8 -*-
"""Toxicity Classifier NLP.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1UUZzQgrRUcLujGxbmhE30AlQALMsYXCm
"""
# Commented out IPython magic to ensure Python compatibility.
@AIAnytime
AIAnytime / noise_reduction
Created July 17, 2022 04:25
Noise is inevitably present in almost all acoustic environments. Even when recorded with a microphone, a speech signal will contain lots of noise, such as white noise or background sounds. Excessive noise can distort or mask the characteristics of s
import noisereduce as nr
from scipy.io import wavfile
# load data
rate, data = wavfile.read("voice_with_noise.wav")
# perform noise reduction
reduced_noise = nr.reduce_noise(y=data, sr=rate) It was originally published on https://www.apriorit.com/
@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