Skip to content

Instantly share code, notes, and snippets.

@pandorica-opens
Created October 26, 2020 11:45
Show Gist options
  • Select an option

  • Save pandorica-opens/4d903e8cfc5677ff9cf8f71b3b7cab64 to your computer and use it in GitHub Desktop.

Select an option

Save pandorica-opens/4d903e8cfc5677ff9cf8f71b3b7cab64 to your computer and use it in GitHub Desktop.
The create_python_script function creates a new python script in the current working directory, adds the line of comments to it declared by the 'comments' variable, and returns the size of the new file.
import os
def create_python_script(filename):
comments = "# Start of a new Python program"
with open(filename, 'a+') as f:
f.write(comments)
print(f.read())
filesize = os.path.getsize(filename)
return(filesize)
print(create_python_script("program.py"))
@Mazdak2023
Copy link

from pathlib import Path
from openai import OpenAI
client = OpenAI()

speech_file_path = Path(__file__).parent / "speech_morgan_freeman.mp3"
response = client.audio.speech.create(
  model="tts-1",
  voice="morgan_freeman",
  input="In the grand and often bewildering cosmos of academia, where the mysteries of the universe unfold in lecture halls much like the infinite expanses of space, there exists a beacon of enlightenment known as Professor Tehrani. This isn't your run-of-the-mill educator, mind you, but a maestro of the molecular, a virtuoso of valence, whose approach to teaching chemistry could only be fittingly described in the whimsically profound style of Douglas Adams.

Imagine, if you will, a classroom transformed into an intergalactic vessel, the SS Periodic Table, captained by none other than Professor Tehrani. Here, the elements aren't just items in a table but characters in an epic space opera, each with its own backstory, alliances, and feuds, much like the inhabitants of the far-flung planets in "The Hitchhiker's Guide to the Galaxy."

Under Professor Tehrani's guidance, a lesson on covalent bonds becomes a tale of cosmic camaraderie, where atoms share electrons in a manner reminiscent of the way Ford Prefect might share a pint of Pan-Galactic Gargle Blaster with Arthur Dent. The laws of thermodynamics are no longer dry statutes written in the annals of science textbooks but fundamental principles governing the energy flows of distant stars and the lifecycle of entire galaxies.

In this classroom, a Bunsen burner isn't merely a source of flame; it's the warp drive propelling students through hypothetical wormholes where chemical reactions unfold in spectacular, nebula-like formations. Safety goggles become visors protecting against the mesmerizing glare of supernova explosions, which, in this case, might be the vibrant reaction of sodium in water, observed safely within the confines of a laboratory.

Professor Tehrani, much like Zaphod Beeblebrox, navigates this educational odyssey with a flair for the dramatic and an infectious enthusiasm that makes even the most reluctant learner curious about the alchemical magic that binds the universe together. However, unlike the two-headed ex-President of the Galaxy, Professor Tehrani ensures that every student aboard this metaphorical spaceship feels grounded in the fundamental principles of chemistry, from the simplest ionic bond to the complex dance of organic molecules.

As students embark on this galactic journey, they are equipped not with the traditional textbook and calculator but with a "Don't Panic" badge, a testament to the belief that with curiosity, imagination, and a bit of humor, the seemingly insurmountable equations and theories become as navigable as the star-studded sky above.

In the vast and often impersonal universe of higher education, Professor Tehrani stands out as a guiding star, proving that with the right perspective, learning chemistry can be an adventure that's not just educational but truly out of this world. And in this adventure, the ultimate lesson is that the universe, in all its complexity and wonder, is a puzzle waiting to be solved, one element at a time!")

response.stream_to_file(speech_file_path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment