Skip to content

Instantly share code, notes, and snippets.

View EnkrateiaLucca's full-sized avatar

LUCAS SOARES EnkrateiaLucca

View GitHub Profile
@EnkrateiaLucca
EnkrateiaLucca / record_audio_with_arecord.py
Created July 9, 2023 22:06
record audio using arecord cli tool from within Python
import os
import subprocess
import time
def record_audio():
audio_file_path = "audio_output.wav"
command = 'arecord -f cd -r 16000 ' + audio_file_path
subprocess.run(command, shell=True)
import openai
import os
openai.api_key = os.environ["OPENAI_API_KEY"]
def get_chatgpt_response(prompt_question):
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful coding and learning assistant."},
@EnkrateiaLucca
EnkrateiaLucca / chat_app_streamlit.py
Created July 7, 2023 18:06
ChatGPT like app in 38 lines of code with streamlit
import openai
import streamlit as st
import os
st.title("ChatGPT Like APP")
openai.api_key = os.environ["OPENAI_API_KEY"]
#if "openai_model" not in st.session_state:
st.session_state["openai_model"] = st.sidebar.selectbox("Select your openai model!",["gpt-3.5-turbo", "gpt-4"])
@EnkrateiaLucca
EnkrateiaLucca / fetch_paper.py
Created May 28, 2023 10:24
fetch arxiv paper by title
# 1. Fetch a random paper from arxiv in the fields of: machine learning, AI, nlp, computer vision etc.
import arxiv
import random
import time
import requests
def fetch_paper(title):
"""
@EnkrateiaLucca
EnkrateiaLucca / youtube_query_cli.py
Created May 9, 2023 12:29
CLI tool to query any YouTube video using langchain
import argparse
from langchain.document_loaders import YoutubeLoader
from langchain.indexes import VectorstoreIndexCreator
def main():
parser = argparse.ArgumentParser(description='Query YouTube videos using ChatGPT with langchain package.')
parser.add_argument('url', help='YouTube video URL')
parser.add_argument('query', help='The query you want to ask about the video')
parser.add_argument('-a', '--add_video_info', action='store_true', help='Add video information (default: False)')
@EnkrateiaLucca
EnkrateiaLucca / youtube_query.py
Created May 9, 2023 12:29
Query any YouTube video with LangChain
DELETE ME - Must create a new gist with an initial file
@EnkrateiaLucca
EnkrateiaLucca / learning_index_file.html
Last active May 7, 2023 12:16
Index file for the learning app
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Learning Feed</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
from flask import Flask, render_template, request
import openai
import os
# Set up the API key
openai.api_key = "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"
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
@EnkrateiaLucca
EnkrateiaLucca / learning_app_examples.py
Created May 5, 2023 16:49
Create a simple learning app with flask and ChatGPT
from flask import Flask, render_template, request
import openai
import os
# Set up the API key
openai.api_key = "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"
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
from tensorflow.keras.models import load_model
import numpy as np
import cv2
import random
import glob
import pickle
def show_image(img,title=""):
cv2.imshow(title, img)