Automating Handwriting With Calligrapher.ai

avatar

handwriting.png

These days there are many AI tools that try to imitate various human actions. Calligrapher.ai is one of these tools. It is an app that converts text input into a handwritten form. Go to the website and give it a try yourself. It is a very simple app but does something very powerful. There is not much need for handwritten notes these days. Most people prefer typing on their devices. If we want our text look like handwritten text we can utilize fonts to do that. However, that still doesn't make it handwritten. There is something unique about handwritten words. Everybody has different handwriting, and such notes like letters demonstrate more effort than something that is typed in.

What makes calligrapher.ai different from choices available is that it generates random handwriting every time, and truly makes the the text look like a human wrote the text. It gives few configuration options. We can changes the speed, legibility, and stroke width of the text. It also gives nine different styles option. If we have a long text to convert to handwritten form and want to keep the style of writing consistent, choosing one style might be better rather than letting the app chose them randomly. For many this may not be a useful tool at all, but it is still fun to play with.

In this post I would like to share how to automate converting text into handwritten svg format and save them in our machines for future use. To accomplish this we will use Selenium to launch the app and do the repetitive actions. The code shared below can be used a template for such projects or any other project that involves Selenium. There is something fun, and there is something to learn in this post.

I didn't come across this tool and the project by accident. I did have project with a real use case last week and small part of it involved using calligrapher.ai with Selenium. Initially, I didn't want to use Selenium, because I thought there had to be a python library that did what calligrapher does. There was one. However, I couldn't get it to work properly due to code being old, and updates in the various libraries made certain classes and functions become obsolete and not work. I do believe given enough time that could have been resolved, and code could be refactored to achieve the goal. But that would require more time, which I didn't have at the time. Hence, automating with Selenium was a faster option.

The purpose of the code below is to take a list of text, convert them to handwritten format in a style of our choosing and saving them as svg files. The list of text can be short to do list, song lyrics, poems, letters, or something even much longer. We can utilize document manipulating and/or creating libraries and add our svg files into them. That is not included in this post. I may cover that step in future posts. Let me know if that is something you are would be interested in.

import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ActionChains
from selenium.webdriver.support.ui import Select

def get_text():
    text_list = ['Hive is a decentralized blockchain network.',
                 'Hive power the next generation of web.',
                 'True ownership of property is possible with tech and networks like Hive.',
                 'Building communities and tools to benefit the humanity is what Hive does.']
    return text_list

def get_calligrapher():
    calli_url = "https://www.calligrapher.ai"
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get(calli_url)
    speed_slider = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, 'speed-slider')))
    ActionChains(driver).drag_and_drop_by_offset(speed_slider, 40, 0).perform()
    bias_slider = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, 'bias-slider')))
    ActionChains(driver).drag_and_drop_by_offset(bias_slider, 20, 0).perform()
    width_slider = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, 'width-slider')))
    ActionChains(driver).drag_and_drop_by_offset(width_slider, 20, 0).perform()
    select = Select(driver.find_element('id', 'select-style'))
    select.select_by_visible_text('9')
    return driver

def get_calligrapher_text(driver, text):
    text_input = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, 'text-input')))
    text_input.clear()
    text_input.send_keys(text)
    draw_button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, 'draw-button')))
    draw_button.click()
    time.sleep(3)
    save_button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, 'save-button')))
    save_button.click()
    time.sleep(1)

def main():
    text_list = get_text()
    driver = get_calligrapher()
    for text in text_list:
        get_calligrapher_text(driver, text)

if __name__ == "__main__":
    main()

We start our code in our main() function which only have four lines and utilizing three other functions: get_text(), get_calligrapher(), get_calligrapher_text(). Simple enough.

First we need our list of text that we are planning to convert to handwritten format. Important thing to mention here is that the app only accepts 50 character long text. Anything longer than 50 characters is truncated. If we are not mindful of this, we may lost some parts of our text. We do want to prep our text keeping this fact in mind. My sample text doesn't follow this. If you were to test, you would see that not all letters have been displayed.

Get_calligrapher() function launches the app and makes the initial configuration changes. The app is very simple, identifying all the elements to use with Selenium was super easy. There aren't many elements either. Three elements we make changes to are sliders and configure the speed, legibility, and stroke width of the text. The fourth element we make changes to is the styles option. I selected number 9 style for testing purposes. But all nine styles are good. So, this function launches the app and makes the initial configuration changes per our liking.

The main action happens in the last function, get_calligrapher_text(). Here we input our text. Since we will be repeating the same process and inputting many texts, we want to make sure we clear the input field first. Otherwise it will keep adding the text to the previous ones. Draw button will draw the text in handwritten format on the screen. Lastly, we click the save button and the svg file will end up in our downloads folder. I used three second sleep before saving the file. Not doing so resulted on saved file only having parts of the text.

Now you too can automate handwriting with calligrapher.ai. Nothing complicated here. This is just a template to get started. Let me know what you think about the app in the comments.



0
0
0.000
20 comments
avatar

Interesting script.

Congrats!

0
0
0.000
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

0
0
0.000
avatar

That is quite interesting and I never thought about an AI doing handwritten stuff. Then again, AI can be used for quite a few different things.

0
0
0.000
avatar

There are many ai tools making things easy. I have not used Calligrapher.ai but will be trying it to see how it works. Technology is making life easy and these days ai tools are on fire.

0
0
0.000
avatar

And there the computers steal our identitys aswell😆😆 laughs nah I'm joking but does everything have to be automated nowadays 🤣

0
0
0.000
avatar

🤣🤣 Hahaha! What is remaining again. My Aunty should get AI tool that can cook our food. I've try this one out if my device can handle it.

0
0
0.000
avatar

This is really quite interesting and fascinating to find out of. Artificial intelligence is really changing the world around

0
0
0.000
avatar

This reminds me of one Twitter bot which drew lines on a canvas until its handwriting recognition recognized the drawing as the intended word. Of course this AI tool is much more efficient and produces more readable results.

0
0
0.000
avatar

Is this script php? Or phyton?

Nowadays AI can do a lot, matter of time to do everything

0
0
0.000
avatar

This AI tool is really nice and will make writing easy
Thanks for sharing with us

0
0
0.000
avatar

Intriguing, every time I see new A.I developments. It feels like one a person in being formed and one day every aspect of this technology will merge and send out this being separate from humans with his own world to thrive in.

0
0
0.000
avatar

Another banger A.I, interesting application and cool script. This has the potential of helping people whose handwriting is not impressive. I love the scrip

0
0
0.000
avatar

Calligraphy A.I is a practical solution, one that can easily be adopted by many institutions to help H.R and anyone pushing out Memos consistently.

0
0
0.000
avatar

One thing I know is that nothing can replace hand written anything. But such simple A.I tools are making it easy for me to think humans are going to have it easy. Guess no more laziness everyone has to truly grind to earn their keep. Super innovative. Congratulations!!!

0
0
0.000
avatar

I will come back and speak my mind. Allow me to try it out. I am fascinated by this. Looks like my time of having a bad hand writting is coming to an end.

0
0
0.000
avatar

Wow this is a massive development and I am really proud of this update. It will take the world of writing to another great height

0
0
0.000
avatar

Congratulations @geekgirl! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You published more than 800 posts.
Your next target is to reach 850 posts.
You made more than 10000 comments.
Your next target is to reach 11000 comments.
You got more than 14000 replies.
Your next target is to reach 14500 replies.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out our last posts:

Feedback from the April Hive Power Up Day
Hive Power Up Month Challenge - March 2024 Winners List
Be ready for the May edition of the Hive Power Up Month!
0
0
0.000
avatar

This is an insightful exploration into the union of technology and creativity. The discussion about Calligrapher.ai highlights the unique appeal of handwritten text in a digital age dominated by typed communication.

It's fascinating to see how projects like this not only solve practical problems but also spark curiosity and innovation. Looking forward to more insights from your future posts!

0
0
0.000
avatar

Hello geekgirl!

It's nice to let you know that your article won 🥇 place.
Your post is among the best articles voted 7 days ago by the @hive-lu | King Lucoin Curator by blind-spot

You and your curator receive 0.0217 Lu (Lucoin) investment token and a 12.46% share of the reward from Daily Report 257. Additionally, you can also receive a unique LUGOLD token for taking 1st place. All you need to do is reblog this report of the day with your winnings.

2.png


Invest in the Lu token (Lucoin) and get paid. With 50 Lu in your wallet, you also become the curator of the @hive-lu which follows your upvote.
Buy Lu on the Hive-Engine exchange | World of Lu created by @szejq

If you no longer want to receive notifications, reply to this comment with the word STOP or to resume write a word START

0
0
0.000