OpenAI API Alchemy: Turn a script into a novel (and vice versa)

Published by

on

OpenAI’s API allows for incredibly intelligent text comprehension and transformation. For fun I made a little application that takes a transcript or script and turns it into a narrative structure for a novel and vice versa.

This means that you can input dialog and add some simple instructions and get a narrative form back (and it will keep adding to it):

I was asked to convert this script into a written story:

"""
DR JANE ELDER
Where do you think you’re going?

Elder has a ray gun pointed at the man in the grey ski mask.

MAN
Stay out of this!

He starts to move towards the door.

DR JANE ELDER
Bad move.

She fires the gun over his head.

DR JANE ELDER
If you want to walk out of here with anything above your neck I suggest you put the computer down and lay on the floor.

"""

This is what I wrote:

Will return this:

It was a tense situation. Dr. Jane Elder was trapped in a tiny exam room with a fleeing patient and a masked gunman holding her at gunpoint.

"Put the computer down!" Dr. Elder demanded.

"Stay out of this!," the man in the ski mask yelled as he edged towards the door.

"Bad move," Dr. Elder warned.

She took a step towards him. Then she raised the gun and fired a shot over his head.

"If you want to walk out of here with anything above your neck I suggest you put the computer down and lay on the floor," Dr. Elder demanded.

You can let it keep writing and it might take you where you want to go:

Dr. Elder took another step toward him. The masked gunman squatted on the floor with the computer on his lap.

Dr. Elder took one step and kicked the computer out of his hands.

"Okay, I’ll play," the masked gunman laughed. "Give me a second while I turn this off."

Dr. Elder knelt down beside the computer and unplugged the cable. The masked gunman stood up. He was holding a remote control in his right hand.

Dr. Elder was still crouching with the computer on the floor when he pushed the button on the remote control and all the metal doors in the room slammed shut with a loud clank.

The masked gunman started to laugh.

Dr. Elder reached up to her hip and pulled a gun out of the holster.

The great thing about this capability with the API is that you could use it to take a transcript of a script and quickly transform it into a complete narrative. If you want to add details or have the API emulate a particular style you can provide a script and your own adaptation to show it how you want it to elaborate.

You can also do the reverse with just this prompt followed by narrative text:

I was asked to convert this story into a formatted script:

The API will then elaborate a script from the text you provide. Insane.