diff --git a/config.json b/config.json new file mode 100644 index 0000000..7201e05 --- /dev/null +++ b/config.json @@ -0,0 +1 @@ +{"activate": true, "autoplay": true, "deepspeed_activate": false, "delete_output_wavs": "Disabled", "ip_address": "127.0.0.1", "language": "English", "low_vram": false, "model_loaded": true, "model_name": "tts_models/multilingual/multi-dataset/xtts_v2", "output_folder_wav": "extensions/coqui_tts/outputs/", "port_number": "7851", "remove_trailing_dots": false, "show_text": true, "tts_method_api_local": false, "tts_method_api_tts": false, "tts_method_xtts_local": true, "voice": "female_01.wav"} \ No newline at end of file diff --git a/harvard_sentences.txt b/harvard_sentences.txt new file mode 100644 index 0000000..1947d9c --- /dev/null +++ b/harvard_sentences.txt @@ -0,0 +1,720 @@ +The birch canoe slid on the smooth planks. +Glue the sheet to the dark blue background. +It's easy to tell the depth of a well. +These days a chicken leg is a rare dish. +Rice is often served in round bowls. +The juice of lemons makes fine punch. +The box was thrown beside the parked truck. +The hogs were fed chopped corn and garbage. +Four hours of steady work faced us. +A large size in stockings is hard to sell. +The boy was there when the sun rose. +A rod is used to catch pink salmon. +The source of the huge river is the clear spring. +Kick the ball straight and follow through. +Help the woman get back to her feet. +A pot of tea helps to pass the evening. +Smoky fires lack flame and heat. +The soft cushion broke the man's fall. +The salt breeze came across from the sea. +The girl at the booth sold fifty bonds. +The small pup gnawed a hole in the sock. +The fish twisted and turned on the bent hook. +Press the pants and sew a button on the vest. +The swan dive was far short of perfect. +The beauty of the view stunned the young boy. +Two blue fish swam in the tank. +Her purse was full of useless trash. +The colt reared and threw the tall rider. +It snowed, rained, and hailed the same morning. +Read verse out loud for pleasure. +Hoist the load to your left shoulder. +Take the winding path to reach the lake. +Note closely the size of the gas tank. +Wipe the grease off his dirty face. +Mend the coat before you go out. +The wrist was badly strained and hung limp. +The stray cat gave birth to kittens. +The young girl gave no clear response. +The meal was cooked before the bell rang. +What joy there is in living. +A king ruled the state in the early days. +The ship was torn apart on the sharp reef. +Sickness kept him home the third week. +The wide road shimmered in the hot sun. +The lazy cow lay in the cool grass. +Lift the square stone over the fence. +The rope will bind the seven books at once. +Hop over the fence and plunge in. +The friendly gang left the drug store. +Mesh wire keeps chicks inside. +The frosty air passed through the coat. +The crooked maze failed to fool the mouse. +Adding fast leads to wrong sums. +The show was a flop from the very start. +A saw is a tool used for making boards. +The wagon moved on well oiled wheels. +March the soldiers past the next hill. +A cup of sugar makes sweet fudge. +Place a rosebush near the porch steps. +Both lost their lives in the raging storm. +We talked of the side show in the circus. +Use a pencil to write the first draft. +He ran half way to the hardware store. +The clock struck to mark the third period. +A small creek cut across the field. +Cars and busses stalled in snow drifts. +The set of china hit the floor with a crash. +This is a grand season for hikes on the road. +The dune rose from the edge of the water. +Those words were the cue for the actor to leave. +A yacht slid around the point into the bay. +The two met while playing on the sand. +The ink stain dried on the finished page. +The walled town was seized without a fight. +The lease ran out in sixteen weeks. +A tame squirrel makes a nice pet. +The horn of the car woke the sleeping cop. +The heart beat strongly and with firm strokes. +The pearl was worn in a thin silver ring. +The fruit peel was cut in thick slices. +The Navy attacked the big task force. +See the cat glaring at the scared mouse. +There are more than two factors here. +The hat brim was wide and too droopy. +The lawyer tried to lose his case. +The grass curled around the fence post. +Cut the pie into large parts. +Men strive but seldom get rich. +Always close the barn door tight. +He lay prone and hardly moved a limb. +The slush lay deep along the street. +A wisp of cloud hung in the blue air. +A pound of sugar costs more than eggs. +The fin was sharp and cut the clear water. +The play seems dull and quite stupid. +Bail the boat to stop it from sinking. +The term ended in late June that year. +A tusk is used to make costly gifts. +Ten pins were set in order. +The bill was paid every third week. +Oak is strong and also gives shade. +Cats and dogs each hate the other. +The pipe began to rust while new. +Open the crate but don't break the glass. +Add the sum to the product of these three. +Thieves who rob friends deserve jail. +The ripe taste of cheese improves with age. +Act on these orders with great speed. +The hog crawled under the high fence. +Move the vat over the hot fire. +The bark of the pine tree was shiny and dark. +Leaves turn brown and yellow in the fall. +The pennant waved when the wind blew. +Split the log with a quick, sharp blow. +Burn peat after the logs give out. +He ordered peach pie with ice cream. +Weave the carpet on the right hand side. +Hemp is a weed found in parts of the tropics. +A lame back kept his score low. +We find joy in the simplest things. +Type out three lists of orders. +The harder he tried the less he got done. +The boss ran the show with a watchful eye. +The cup cracked and spilled its contents. +Paste can cleanse the most dirty brass. +The slang word for raw whiskey is booze. +It caught its hind paw in a rusty trap. +The wharf could be seen at the farther shore. +Feel the heat of the weak dying flame. +The tiny girl took off her hat. +A cramp is no small danger on a swim. +He said the same phrase thirty times. +Pluck the bright rose without leaves. +Two plus seven is less than ten. +The glow deepened in the eyes of the sweet girl. +Bring your problems to the wise chief. +Write a fond note to the friend you cherish. +Clothes and lodging are free to new men. +We frown when events take a bad turn. +Port is a strong wine with a smoky taste. +The young kid jumped the rusty gate. +Guess the results from the first scores. +A salt pickle tastes fine with ham. +The just claim got the right verdict. +These thistles bend in a high wind. +Pure bred poodles have curls. +The tree top waved in a graceful way. +The spot on the blotter was made by green ink. +Mud was spattered on the front of his white shirt. +The cigar burned a hole in the desk top. +The empty flask stood on the tin tray. +A speedy man can beat this track mark. +He broke a new shoelace that day. +The coffee stand is too high for the couch. +The urge to write short stories is rare. +The pencils have all been used. +The pirates seized the crew of the lost ship. +We tried to replace the coin but failed. +She sewed the torn coat quite neatly. +The sofa cushion is red and of light weight. +The jacket hung on the back of the wide chair. +At that high level the air is pure. +Drop the two when you add the figures. +A filing case is now hard to buy. +An abrupt start does not win the prize. +Wood is best for making toys and blocks. +The office paint was a dull, sad tan. +He knew the skill of the great young actress. +A rag will soak up spilled water. +A shower of dirt fell from the hot pipes. +Steam hissed from the broken valve. +The child almost hurt the small dog. +There was a sound of dry leaves outside. +The sky that morning was clear and bright blue. +Torn scraps littered the stone floor. +Sunday is the best part of the week. +The doctor cured him with these pills. +The new girl was fired today at noon. +They felt gay when the ship arrived in port. +Add the store's account to the last cent. +Acid burns holes in wool cloth. +Fairy tales should be fun to write. +Eight miles of woodland burned to waste. +The third act was dull and tired the players. +A young child should not suffer fright. +Add the column and put the sum here. +We admire and love a good cook. +There the flood mark is ten inches. +He carved a head from the round block of marble. +She has a smart way of wearing clothes. +The fruit of a fig tree is apple-shaped. +Corn cobs can be used to kindle a fire. +Where were they when the noise started. +The paper box is full of thumb tacks. +Sell your gift to a buyer at a good gain. +The tongs lay beside the ice pail. +The petals fall with the next puff of wind. +Bring your best compass to the third class. +They could laugh although they were sad. +Farmers came in to thresh the oat crop. +The brown house was on fire to the attic. +The lure is used to catch trout and flounder. +Float the soap on top of the bath water. +A blue crane is a tall wading bird. +A fresh start will work such wonders. +The club rented the rink for the fifth night. +After the dance, they went straight home. +The hostess taught the new maid to serve. +He wrote his last novel there at the inn. +Even the worst will beat his low score. +The cement had dried when he moved it. +The loss of the second ship was hard to take. +The fly made its way along the wall. +Do that with a wooden stick. +Live wires should be kept covered. +The large house had hot water taps. +It is hard to erase blue or red ink. +Write at once or you may forget it. +The doorknob was made of bright clean brass. +The wreck occurred by the bank on Main Street. +A pencil with black lead writes best. +Coax a young calf to drink from a bucket. +Schools for ladies teach charm and grace. +The lamp shone with a steady green flame. +They took the axe and the saw to the forest. +The ancient coin was quite dull and worn. +The shaky barn fell with a loud crash. +Jazz and swing fans like fast music. +Rake the rubbish up and then burn it. +Slash the gold cloth into fine ribbons. +Try to have the court decide the case. +They are pushed back each time they attack. +He broke his ties with groups of former friends. +They floated on the raft to sun their white backs. +The map had an X that meant nothing. +Whitings are small fish caught in nets. +Some ads serve to cheat buyers. +Jerk the rope and the bell rings weakly. +A waxed floor makes us lose balance. +Madam, this is the best brand of corn. +On the islands the sea breeze is soft and mild. +The play began as soon as we sat down. +This will lead the world to more sound and fury. +Add salt before you fry the egg. +The rush for funds reached its peak Tuesday. +The birch looked stark white and lonesome. +The box is held by a bright red snapper. +To make pure ice, you freeze water. +The first worm gets snapped early. +Jump the fence and hurry up the bank. +Yell and clap as the curtain slides back. +They are men who walk the middle of the road. +Both brothers wear the same size. +In some form or other we need fun. +The prince ordered his head chopped off. +The houses are built of red clay bricks. +Ducks fly north but lack a compass. +Fruit flavors are used in fizz drinks. +These pills do less good than others. +Canned pears lack full flavor. +The dark pot hung in the front closet. +Carry the pail to the wall and spill it there. +The train brought our hero to the big town. +We are sure that one war is enough. +Gray paint stretched for miles around. +The rude laugh filled the empty room. +High seats are best for football fans. +Tea served from the brown jug is tasty. +A dash of pepper spoils beef stew. +A zestful food is the hot-cross bun. +The horse trotted around the field at a brisk pace. +Find the twin who stole the pearl necklace. +Cut the cord that binds the box tightly. +The red tape bound the smuggled food. +Look in the corner to find the tan shirt. +The cold drizzle will halt the bond drive. +Nine men were hired to dig the ruins. +The junk yard had a mouldy smell. +The flint sputtered and lit a pine torch. +Soak the cloth and drown the sharp odor. +The shelves were bare of both jam or crackers. +A joy to every child is the swan boat. +All sat frozen and watched the screen. +A cloud of dust stung his tender eyes. +To reach the end he needs much courage. +Shape the clay gently into block form. +A ridge on a smooth surface is a bump or flaw. +Hedge apples may stain your hands green. +Quench your thirst, then eat the crackers. +Tight curls get limp on rainy days. +The mute muffled the high tones of the horn. +The gold ring fits only a pierced ear. +The old pan was covered with hard fudge. +Watch the log float in the wide river. +The node on the stalk of wheat grew daily. +The heap of fallen leaves was set on fire. +Write fast if you want to finish early. +His shirt was clean but one button was gone. +The barrel of beer was a brew of malt and hops. +Tin cans are absent from store shelves. +Slide the box into that empty space. +The plant grew large and green in the window. +The beam dropped down on the workmen's head. +Pink clouds floated with the breeze. +She danced like a swan, tall and graceful. +The tube was blown and the tire flat and useless. +It is late morning on the old wall clock. +Let's all join as we sing the last chorus. +The last switch cannot be turned off. +The fight will end in just six minutes. +The store walls were lined with colored frocks. +The peace league met to discuss their plans. +The rise to fame of a person takes luck. +Paper is scarce, so write with much care. +The quick fox jumped on the sleeping cat. +The nozzle of the fire hose was bright brass. +Screw the round cap on as tight as needed. +Time brings us many changes. +The purple tie was ten years old. +Men think and plan and sometimes act. +Fill the ink jar with sticky glue. +He smoke a big pipe with strong contents. +We need grain to keep our mules healthy. +Pack the records in a neat thin case. +The crunch of feet in the snow was the only sound. +The copper bowl shone in the sun's rays. +Boards will warp unless kept dry. +The plush chair leaned against the wall. +Glass will clink when struck by metal. +Bathe and relax in the cool green grass. +Nine rows of soldiers stood in line. +The beach is dry and shallow at low tide. +The idea is to sew both edges straight. +The kitten chased the dog down the street. +Pages bound in cloth make a book. +Try to trace the fine lines of the painting. +Women form less than half of the group. +The zones merge in the central part of town. +A gem in the rough needs work to polish. +Code is used when secrets are sent. +Most of the news is easy for us to hear. +He used the lathe to make brass objects. +The vane on top of the pole revolved in the wind. +Mince pie is a dish served to children. +The clan gathered on each dull night. +Let it burn, it gives us warmth and comfort. +A castle built from sand fails to endure. +A child's wit saved the day for us. +Tack the strip of carpet to the worn floor. +Next Tuesday we must vote. +Pour the stew from the pot into the plate. +Each penny shone like new. +The man went to the woods to gather sticks. +The dirt piles were lines along the road. +The logs fell and tumbled into the clear stream. +Just hoist it up and take it away. +A ripe plum is fit for a king's palate. +Our plans right now are hazy. +Brass rings are sold by these natives. +It takes a good trap to capture a bear. +Feed the white mouse some flower seeds. +The thaw came early and freed the stream. +He took the lead and kept it the whole distance. +The key you designed will fit the lock. +Plead to the council to free the poor thief. +Better hash is made of rare beef. +This plank was made for walking on. +The lake sparkled in the red hot sun. +He crawled with care along the ledge. +Tend the sheep while the dog wanders. +It takes a lot of help to finish these. +Mark the spot with a sign painted red. +Take two shares as a fair profit. +The fur of cats goes by many names. +North winds bring colds and fevers. +He asks no person to vouch for him. +Go now and come here later. +A sash of gold silk will trim her dress. +Soap can wash most dirt away. +That move means the game is over. +He wrote down a long list of items. +A siege will crack the strong defense. +Grape juice and water mix well. +Roads are paved with sticky tar. +Fake stones shine but cost little. +The drip of the rain made a pleasant sound. +Smoke poured out of every crack. +Serve the hot rum to the tired heroes. +Much of the story makes good sense. +The sun came up to light the eastern sky. +Heave the line over the port side. +A lathe cuts and trims any wood. +It's a dense crowd in two distinct ways. +His hip struck the knee of the next player. +The stale smell of old beer lingers. +The desk was firm on the shaky floor. +It takes heat to bring out the odor. +Beef is scarcer than some lamb. +Raise the sail and steer the ship northward. +A cone costs five cents on Mondays. +A pod is what peas always grow in. +Jerk the dart from the cork target. +No cement will hold hard wood. +We now have a new base for shipping. +A list of names is carved around the base. +The sheep were led home by a dog. +Three for a dime, the young peddler cried. +The sense of smell is better than that of touch. +No hardship seemed to keep him sad. +Grace makes up for lack of beauty. +Nudge gently but wake her now. +The news struck doubt into restless minds. +Once we stood beside the shore. +A chink in the wall allowed a draft to blow. +Fasten two pins on each side. +A cold dip restores health and zest. +He takes the oath of office each March. +The sand drifts over the sill of the old house. +The point of the steel pen was bent and twisted. +There is a lag between thought and act. +Seed is needed to plant the spring corn. +Draw the chart with heavy black lines. +The boy owed his pal thirty cents. +The chap slipped into the crowd and was lost. +Hats are worn to tea and not to dinner. +The ramp led up to the wide highway. +Beat the dust from the rug onto the lawn. +Say it slowly but make it ring clear. +The straw nest housed five robins. +Screen the porch with woven straw mats. +This horse will nose his way to the finish. +The dry wax protects the deep scratch. +He picked up the dice for a second roll. +These coins will be needed to pay his debt. +The nag pulled the frail cart along. +Twist the valve and release hot steam. +The vamp of the shoe had a gold buckle. +The smell of burned rags itches my nose. +New pants lack cuffs and pockets. +The marsh will freeze when cold enough. +They slice the sausage thin with a knife. +The bloom of the rose lasts a few days. +A gray mare walked before the colt. +Breakfast buns are fine with a hot drink. +Bottles hold four kinds of rum. +The man wore a feather in his felt hat. +He wheeled the bike past the winding road. +Drop the ashes on the worn old rug. +The desk and both chairs were painted tan. +Throw out the used paper cup and plate. +A clean neck means a neat collar. +The couch cover and hall drapes were blue. +The stems of the tall glasses cracked and broke. +The wall phone rang loud and often. +The clothes dried on a thin wooden rack. +Turn on the lantern which gives us light. +The cleat sank deeply into the soft turf. +The bills were mailed promptly on the tenth of the month. +To have is better than to wait and hope. +The price is fair for a good antique clock. +The music played on while they talked. +Dispense with a vest on a day like this. +The bunch of grapes was pressed into wine. +He sent the figs, but kept the ripe cherries. +The hinge on the door creaked with old age. +The screen before the fire kept in the sparks. +Fly by night, and you waste little time. +Thick glasses helped him read the print. +Birth and death mark the limits of life. +The chair looked strong but had no bottom. +The kite flew wildly in the high wind. +A fur muff is stylish once more. +The tin box held priceless stones. +We need an end of all such matter. +The case was puzzling to the old and wise. +The bright lanterns were gay on the dark lawn. +We don't get much money but we have fun. +The youth drove with zest, but little skill. +Five years he lived with a shaggy dog. +A fence cuts through the corner lot. +The way to save money is not to spend much. +Shut the hatch before the waves push it in. +The odor of spring makes young hearts jump. +Crack the walnut with your sharp side teeth. +He offered proof in the form of a large chart. +Send the stuff in a thick paper bag. +A quart of milk is water for the most part. +They told wild tales to frighten him. +The three story house was built of stone. +In the rear of the ground floor was a large passage. +A man in a blue sweater sat at the desk. +Oats are a food eaten by horse and man. +Their eyelids droop for want of sleep. +A sip of tea revives his tired friend. +There are many ways to do these things. +Tuck the sheet under the edge of the mat. +A force equal to that would move the earth. +We like to see clear weather. +The work of the tailor is seen on each side. +Take a chance and win a china doll. +Shake the dust from your shoes, stranger. +She was kind to sick old people. +The square wooden crate was packed to be shipped. +The dusty bench stood by the stone wall. +We dress to suit the weather of most days. +Smile when you say nasty words. +A bowl of rice is free with chicken stew. +The water in this well is a source of good health. +Take shelter in this tent, but keep still. +That guy is the writer of a few banned books. +The little tales they tell are false. +The door was barred, locked, and bolted as well. +Ripe pears are fit for a queen's table. +A big wet stain was on the round carpet. +The kite dipped and swayed, but stayed aloft. +The pleasant hours fly by much too soon. +The room was crowded with a wild mob. +This strong arm shall shield your honor. +She blushed when he gave her a white orchid. +The beetle droned in the hot June sun. +Press the pedal with your left foot. +Neat plans fail without luck. +The black trunk fell from the landing. +The bank pressed for payment of the debt. +The theft of the pearl pin was kept secret. +Shake hands with this friendly child. +The vast space stretched into the far distance. +A rich farm is rare in this sandy waste. +His wide grin earned many friends. +Flax makes a fine brand of paper. +Hurdle the pit with the aid of a long pole. +A strong bid may scare your partner stiff. +Even a just cause needs power to win. +Peep under the tent and see the clowns. +The leaf drifts along with a slow spin. +Cheap clothes are flashy but don't last. +A thing of small note can cause despair. +Flood the mails with requests for this book. +A thick coat of black paint covered all. +The pencil was cut to be sharp at both ends. +Those last words were a strong statement. +He wrote his name boldly at the top of the sheet. +Dill pickles are sour but taste fine. +Down that road is the way to the grain farmer. +Either mud or dust are found at all times. +The best method is to fix it in place with clips. +If you mumble your speech will be lost. +At night the alarm roused him from a deep sleep. +Read just what the meter says. +Fill your pack with bright trinkets for the poor. +The small red neon lamp went out. +Clams are small, round, soft, and tasty. +The fan whirled its round blades softly. +The line where the edges join was clean. +Breathe deep and smell the piny air. +It matters not if he reads these words or those. +A brown leather bag hung from its strap. +A toad and a frog are hard to tell apart. +A white silk jacket goes with any shoes. +A break in the dam almost caused a flood. +Paint the sockets in the wall dull green. +The child crawled into the dense grass. +Bribes fail where honest men work. +Trample the spark, else the flames will spread. +The hilt of the sword was carved with fine designs. +A round hole was drilled through the thin board. +Footprints showed the path he took up the beach. +She was waiting at my front lawn. +A vent near the edge brought in fresh air. +Prod the old mule with a crooked stick. +It is a band of steel three inches wide. +The pipe ran almost the length of the ditch. +It was hidden from sight by a mass of leaves and shrubs. +The weight of the package was seen on the high scale. +Wake and rise, and step into the green outdoors. +The green light in the brown box flickered. +The brass tube circled the high wall. +The lobes of her ears were pierced to hold rings. +Hold the hammer near the end to drive the nail. +Next Sunday is the twelfth of the month. +Every word and phrase he speaks is true. +He put his last cartridge into the gun and fired. +They took their kids from the public school. +Drive the screw straight into the wood. +Keep the hatch tight and the watch constant. +Sever the twine with a quick snip of the knife. +Paper will dry out when wet. +Slide the catch back and open the desk. +Help the weak to preserve their strength. +A sullen smile gets few friends. +Stop whistling and watch the boys march. +Jerk the cord, and out tumbles the gold. +Slide the tray across the glass top. +The cloud moved in a stately way and was gone. +Light maple makes for a swell room. +Set the piece here and say nothing. +Dull stories make her laugh. +A stiff cord will do to fasten your shoe. +Get the trust fund to the bank early. +Choose between the high road and the low. +A plea for funds seems to come again. +He lent his coat to the tall gaunt stranger. +There is a strong chance it will happen once more. +The duke left the park in a silver coach. +Greet the new guests and leave quickly. +When the frost has come it is time for turkey. +Sweet words work better than fierce. +A thin stripe runs down the middle. +A six comes up more often than a ten. +Lush fern grow on the lofty rocks. +The ram scared the school children off. +The team with the best timing looks good. +The farmer swapped his horse for a brown ox. +Sit on the perch and tell the others what to do. +A steep trail is painful for our feet. +The early phase of life moves fast. +Green moss grows on the northern side. +Tea in thin china has a sweet taste. +Pitch the straw through the door of the stable. +The latch on the back gate needed a nail. +The goose was brought straight from the old market. +The sink is the thing in which we pile dishes. +A whiff of it will cure the most stubborn cold. +The facts don't always show who is right. +She flaps her cape as she parades the street. +The loss of the cruiser was a blow to the fleet. +Loop the braid to the left and then over. +Plead with the lawyer to drop the lost cause. +Calves thrive on tender spring grass. +Post no bills on this office wall. +Tear a thin sheet from the yellow pad. +A cruise in warm waters in a sleek yacht is fun. +A streak of color ran down the left edge. +It was done before the boy could see it. +Crouch before you jump or miss the mark. +Pack the kits and don't forget the salt. +The square peg will settle in the round hole. +Fine soap saves tender skin. +Poached eggs and tea must suffice. +Bad nerves are jangled by a door slam. +Ship maps are different from those for planes. +Dimes showered down from all sides. +They sang the same tunes at each party. +The sky in the west is tinged with orange red. +The pods of peas ferment in bare fields. +The horse balked and threw the tall rider. +The hitch between the horse and cart broke. +Pile the coal high in the shed corner. +A gold vase is both rare and costly. +The knife was hung inside its bright sheath. +The rarest spice comes from the far East. +The roof should be tilted at a sharp slant. +A smatter of French is worse than none. +The mule trod the treadmill day and night. +The aim of the contest is to raise a great fund. +To send it now in large amounts is bad. +There is a fine hard tang in salty air. +Cod is the main business of the north shore. +The slab was hewn from heavy blocks of slate. +Dunk the stale biscuits into strong drink. +Hang tinsel from both branches. +Cap the jar with a tight brass cover. +The poor boy missed the boat again. +Be sure to set the lamp firmly in the hole. +Pick a card and slip it under the pack. +A round mat will cover the dull spot. +The first part of the plan needs changing. +A good book informs of what we ought to know. +The mail comes in three batches per day. +You cannot brew tea in a cold pot. +Dots of light betrayed the black cat. +Put the chart on the mantel and tack it down. +The night shift men rate extra pay. +The red paper brightened the dim stage. +See the player scoot to third base. +Slide the bill between the two leaves. +Many hands help get the job done. +We don't like to admit our small faults. +No doubt about the way the wind blows. +Dig deep in the earth for pirate's gold. +The steady drip is worse than a drenching rain. +A flat pack takes less luggage space. +Green ice frosted the punch bowl. +A stuffed chair slipped from the moving van. +The stitch will serve but needs to be shortened. +A thin book fits in the side pocket. +The gloss on top made it unfit to read. +The hail pattered on the burnt brown grass. +Seven seals were stamped on great sheets. +Our troops are set to strike heavy blows. +The store was jammed before the sale could start. +It was a bad error on the part of the new judge. +One step more and the board will collapse. +Take the match and strike it against your shoe. +The pot boiled, but the contents failed to jell. +The baby puts his right foot in his mouth. +The bombs left most of the town in ruins. +Stop and stare at the hard working man. +The streets are narrow and full of sharp turns. +The pup jerked the leash as he saw a feline shape. +Open your book to the first page. +Fish evade the net and swim off. +Dip the pail once and let it settle. +Will you please answer that phone. +The big red apple fell to the ground. +The curtain rose and the show was on. +The young prince became heir to the throne. +He sent the boy on a short errand. +Leave now and you will arrive on time. +The corner store was robbed last night. +A gold ring will please most any girl. +The long journey home took a year. +She saw a cat in the neighbor's house. +A pink shell was found on the sandy beach. +Small children came to see him. +The grass and bushes were wet with dew. +The blind man counted his old coins. +A severe storm tore down the barn. +She called his name many times. +When you hear the bell, come quickly. \ No newline at end of file diff --git a/languages.json b/languages.json new file mode 100644 index 0000000..3b780e8 --- /dev/null +++ b/languages.json @@ -0,0 +1,18 @@ +{ + "Arabic": "ar", + "Chinese": "zh-cn", + "Czech": "cs", + "Dutch": "nl", + "English": "en", + "French": "fr", + "German": "de", + "Hungarian": "hu", + "Italian": "it", + "Japanese": "ja", + "Korean": "ko", + "Polish": "pl", + "Portuguese": "pt", + "Russian": "ru", + "Spanish": "es", + "Turkish": "tr" +} \ No newline at end of file diff --git a/modeldownload.json b/modeldownload.json new file mode 100644 index 0000000..33ed1e0 --- /dev/null +++ b/modeldownload.json @@ -0,0 +1,11 @@ +{ + "base_path": "models", + "model_path": "xttsv2_2.0.2", + "files_to_download": { + "LICENSE.txt": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/LICENSE.txt?download=true", + "README.md": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/README.md?download=true", + "config.json": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/config.json?download=true", + "model.pth": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/model.pth?download=true", + "vocab.json": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/vocab.json?download=true" + } +} diff --git a/modeldownload.py b/modeldownload.py new file mode 100644 index 0000000..cdbf9d9 --- /dev/null +++ b/modeldownload.py @@ -0,0 +1,95 @@ +import os +from pathlib import Path +import requests +from tqdm import tqdm +import importlib.metadata as metadata +import json +from packaging import version + +# Use this_dir in the downloader script +this_dir = Path(__file__).parent.resolve() + +# Define the path to the JSON file +config_file_path = this_dir / 'modeldownload.json' + +# Check if the JSON file exists +if config_file_path.exists(): + with open(config_file_path, 'r') as config_file: + settings = json.load(config_file) + + # Extract settings from the loaded JSON + base_path = Path(settings.get("base_path", "")) + model_path = Path(settings.get("model_path", "")) + files_to_download = settings.get("files_to_download", {}) +else: + # Default settings if the JSON file doesn't exist or is empty + print("[CoquiTTS Startup] \033[91mWarning\033[0m modeldownload.json is missing so please re-download it and save it in the coquii_tts main folder.") + print("[CoquiTTS Startup] \033[91mWarning\033[0m API Local and XTTSv2 Local will error unless this is corrected.") + +# Read the version specifier from requirements.txt +with open(this_dir / 'requirements.txt', 'r') as req_file: + requirements = req_file.readlines() + +tts_version_required = None +for req in requirements: + if req.startswith('TTS=='): + tts_version_required = req.strip().split('==')[1] + break + +if tts_version_required is None: + raise ValueError("[CoquiTTS Startup] \033[91mWarning\033[0m Could not find TTS version specifier in requirements.txt") + +def create_directory_if_not_exists(directory): + if not directory.exists(): + directory.mkdir(parents=True) + +def download_file(url, destination): + response = requests.get(url, stream=True) + total_size_in_bytes = int(response.headers.get('content-length', 0)) + block_size = 1024 # 1 Kibibyte + + progress_bar = tqdm(total=total_size_in_bytes, unit='iB', unit_scale=True) + + with open(destination, 'wb') as file: + for data in response.iter_content(block_size): + progress_bar.update(len(data)) + file.write(data) + + progress_bar.close() + +def check_tts_version(): + try: + tts_version = metadata.version("tts") + print(f"[CoquiTTS Startup] TTS version installed: \033[93m{tts_version}\033[0m") + + if version.parse(tts_version) < version.parse(tts_version_required): + print(f"[CoquiTTS Startup] \033[91mWarning\033[0m TTS version is too old. Please upgrade to version \033[93m{tts_version_required}\033[0m or later.\033[0m") + print("[CoquiTTS Startup] \033[91mWarning\033[0m At your terminal/command prompt \033[94mpip install --upgrade tts\033[0m") + else: + print("[CoquiTTS Startup] TTS version is up to date.") + except metadata.PackageNotFoundError: + print("[CoquiTTS Startup] \033[91mWarning\033[0m TTS is not installed.") + +# Check and create directories +if str(base_path) == "models": + create_directory_if_not_exists(this_dir / base_path / model_path) +else: + create_directory_if_not_exists(base_path / model_path) + print("[CoquiTTS Startup] \033[94mInfo\033[0m Custom path set in \033[93mmodeldownload.json\033[0m. Using the following settings:") + print("[CoquiTTS Startup] \033[94mInfo\033[0m Base folder Path:\033[93m", base_path , "\033[0m") + print("[CoquiTTS Startup] \033[94mInfo\033[0m Model folder Path:\033[93m", model_path , "\033[0m") + print("[CoquiTTS Startup] \033[94mInfo\033[0m Full Path:\033[93m", base_path / model_path , "\033[0m") + +# Download files if they don't exist +print("[CoquiTTS Startup] Checking Model is Downloaded.") +for filename, url in files_to_download.items(): + if str(base_path) == "models": + destination = this_dir / base_path / model_path / filename + else: + destination = Path(base_path) / model_path / filename + + if not destination.exists(): + print(f"[CoquiTTS Startup] Downloading {filename}...") + download_file(url, destination) + +check_tts_version() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..78949fa --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +TTS==0.21.3 \ No newline at end of file diff --git a/script.py b/script.py new file mode 100644 index 0000000..ef21aab --- /dev/null +++ b/script.py @@ -0,0 +1,504 @@ +import html +import json +import random +import subprocess +import time +import os +import requests +import threading +import signal +import sys +import atexit +from pathlib import Path +from datetime import datetime, timedelta + +import gradio as gr + +from modules import chat, shared, ui_chat +from modules.logging_colors import logger +from modules.ui import create_refresh_button +from modules.utils import gradio + +#Required for sentence splitting +try: + from TTS.api import TTS + from TTS.utils.synthesizer import Synthesizer +except ModuleNotFoundError: + logger.error( + "[CoquiTTS Startup] \033[91mWarning\033[0m Could not find the TTS module. Make sure to install the requirements for the coqui_tts extension." + "[CoquiTTS Startup] \033[91mWarning\033[0m Linux / Mac:\npip install -r extensions/coqui_tts/requirements.txt\n" + "[CoquiTTS Startup] \033[91mWarning\033[0m Windows:\npip install -r extensions\\coqui_tts\\requirements.txt\n" + "[CoquiTTS Startup] \033[91mWarning\033[0m If you used the one-click installer, paste the command above in the terminal window launched after running the \"cmd_\" script. On Windows, that's \"cmd_windows.bat\"." + ) + raise + +#IMPORT - Attempt Importing DeepSpeed +try: + import deepspeed + deepspeed_installed = True +except ImportError: + deepspeed_installed = False + +########################### +#### STARTUP VARIABLES #### +########################### +#STARTUP VARIABLE - Create "this_dir" variable as the current script directory +this_dir = Path(__file__).parent.resolve() +#STARTUP VARIABLE - Import languges file for Gradio to be able to display them in the interface +with open(this_dir / 'languages.json', encoding='utf8') as f: + languages = json.load(f) +# Create a global lock +process_lock = threading.Lock() + +####################################### +#### LOAD PARAMS FROM CONFIG.JSON #### +####################################### +def load_config(file_path): + with open(file_path, 'r') as config_file: + config = json.load(config_file) + return config + +config_file_path = (this_dir / 'config.json') +params = load_config(config_file_path) + +def get_available_voices(): + return sorted([voice.name for voice in Path(f"{this_dir}/voices").glob("*.wav")]) + +######################### +#### LICENSE DISPLAY #### +######################### +#STARTUP Display Licence Information +print("[CoquiTTS Startup] \033[94mCoqui Public Model License\033[0m") +print("[CoquiTTS Startup] \033[94mhttps://coqui.ai/cpml.txt\033[0m") + +############################################ +#### DELETE OLD OUTPUT WAV FILES IF SET #### +############################################ +def delete_old_files(folder_path, days_to_keep): + current_time = datetime.now() + print("[CoquiTTS Startup] Deletion of old output folder WAV files is currently enabled and set at", delete_output_wavs_setting) + for file_name in os.listdir(folder_path): + file_path = os.path.join(folder_path, file_name) + if os.path.isfile(file_path): + file_creation_time = datetime.fromtimestamp(os.path.getctime(file_path)) + age = current_time - file_creation_time + if age > timedelta(days=days_to_keep): + os.remove(file_path) + +# Extract settings using params dictionary +delete_output_wavs_setting = params["delete_output_wavs"] +output_folder_wav = params["output_folder_wav"] +output_folder_wav = os.path.normpath(output_folder_wav) + +# Check and perform file deletion +if delete_output_wavs_setting.lower() == "disabled": + print("[CoquiTTS Startup] Old output wav file deletion is set to disabled.") +else: + try: + days_to_keep = int(delete_output_wavs_setting.split()[0]) + delete_old_files(output_folder_wav, days_to_keep) + except ValueError: + print("[CoquiTTS Startup] Invalid setting for deleting old wav files. Please use 'Disabled' or 'X Days' format.") + +######################## +#### STARTUP CHECKS #### +######################## +#STARTUP Checks routine +def check_required_files(): + this_dir = Path(__file__).parent.resolve() + download_script_path = this_dir / 'modeldownload.py' + subprocess.run(['python', str(download_script_path)]) + print("[CoquiTTS Startup] All required files are present.") + +#STARTUP Call Check routine +check_required_files() + +################################################# +#### SET GRADIO BUTTONS BASED ON CONFIG.JSON #### +################################################# + +if params["tts_method_api_tts"] == True: + gr_modelchoice = "API TTS" +elif params["tts_method_api_local"] == True: + gr_modelchoice = "API Local" +elif params["tts_method_xtts_local"] == True: + gr_modelchoice = "XTTSv2 Local" + +###################### +#### GRADIO STUFF #### +###################### +def remove_tts_from_history(history): + for i, entry in enumerate(history['internal']): + history['visible'][i] = [history['visible'][i][0], entry[1]] + return history + +def toggle_text_in_history(history): + for i, entry in enumerate(history['visible']): + visible_reply = entry[1] + if visible_reply.startswith('\n\n{reply}"] + else: + history['visible'][i] = [history['visible'][i][0], f"{visible_reply.split('')[0]}"] + return history + +def history_modifier(history): + # Remove autoplay from the last reply + if len(history['internal']) > 0: + history['visible'][-1] = [ + history['visible'][-1][0], + history['visible'][-1][1].replace('controls autoplay>', 'controls>') + ] + + return history + +###################################### +#### SUBPROCESS/WEBSERVER STARTUP #### +###################################### +base_url = f"http://{params['ip_address']}:{params['port_number']}" +script_path = this_dir / 'tts_server.py' + +def signal_handler(sig, frame): + print("[CoquiTTS Shutdown] \033[94mReceived Ctrl+C, terminating subprocess\033[92m") + if process.poll() is None: + process.terminate() + process.wait() # Wait for the subprocess to finish + sys.exit(0) + +# Attach the signal handler to the SIGINT signal (Ctrl+C) +signal.signal(signal.SIGINT, signal_handler) + +# Start the subprocess +process = subprocess.Popen(['python', script_path]) + +# Check if the subprocess has started successfully +if process.poll() is None: + print("[CoquiTTS Startup] TTS Subprocess starting") + print("[CoquiTTS Startup] Readme available here:", f"http://{params['ip_address']}:{params['port_number']}") +else: + print("[CoquiTTS Startup] \033[91mWarning\033[0m TTS Subprocess Webserver failing to start process") + print("[CoquiTTS Startup] \033[91mWarning\033[0m It could be that you have something on port:", params['port_number']) + print("[CoquiTTS Startup] \033[91mWarning\033[0m Or you have not started in a Python environement with all the necesssary bits installed") + print("[CoquiTTS Startup] \033[91mWarning\033[0m Check you are starting Text-generation-webui with either the start_xxxxx file or the Python environment with cmd_xxxxx file.") + print("[CoquiTTS Startup] \033[91mWarning\033[0m xxxxx is the type of OS you are on e.g. windows, linux or mac.") + print("[CoquiTTS Startup] \033[91mWarning\033[0m Alternatively, you could check no other Python processes are running that shouldnt be e.g. Restart your computer is the simple way.") + #Cleanly kill off this script, but allow text-generation-webui to keep running, albeit without this coquii_tts + sys.exit(1) + +timeout = 60 # Adjust the timeout as needed + +# Introduce a delay before starting the check loop +time.sleep(25) #Wait 25 secs before checking if the tts_server.py has started up. +start_time = time.time() +while time.time() - start_time < timeout: + try: + response = requests.get(f"{base_url}/ready") + if response.status_code == 200: + break + except requests.RequestException as e: + # Print the exception for debugging purposes + print(f"[CoquiTTS Startup] \033[91mWarning\033[0m TTS Subprocess has NOT started up yet, Will keep trying for 60 seconds maximum") + time.sleep(1) +else: + print("[CoquiTTS Startup] Startup timed out. Check the server logs for more information.") + #Cleanly kill off this script, but allow text-generation-webui to keep running, albeit without this coquii_tts + sys.exit(1) + +##################################### +#### MODEL LOADING AND UNLOADING #### +##################################### +#MODEL - Swap model based on Gradio selection API TTS, API Local, XTTSv2 Local +def send_reload_request(tts_method): + try: + params["model_loaded"] = False + url = f"{base_url}/api/reload" + payload = {"tts_method": tts_method} + response = requests.post(url, params=payload) + response.raise_for_status() # Raises an HTTPError for bad responses + json_response = response.json() + # Check if the reload operation was successful + if json_response.get("status") == "model-success": + # Update model_loaded to True if the reload was successful + params["model_loaded"] = True + return json_response + except requests.exceptions.RequestException as e: + # Handle the HTTP request error + print(f"[CoquiTTS Server] \033[91mWarning\033[0m Error during request to webserver process: {e}") + return {"status": "error", "message": str(e)} + +################## +#### LOW VRAM #### +################## +#LOW VRAM - Gradio Checkbox handling +def send_lowvram_request(low_vram): + try: + params["model_loaded"] = False + url = f"{base_url}/api/lowvramsetting?new_low_vram_value={low_vram}" + headers = {"Content-Type": "application/json"} + response = requests.post(url, headers=headers) + response.raise_for_status() # Raises an HTTPError for bad responses + json_response = response.json() + # Check if the low VRAM request was successful + if json_response.get("status") == "lowvram-success": + # Update any relevant variables or perform other actions on success + params["model_loaded"] = True + return json_response + except requests.exceptions.RequestException as e: + # Handle the HTTP request error + print(f"[CoquiTTS Server] \033[91mWarning\033[0m Error during request to webserver process: {e}") + return {"status": "error", "message": str(e)} + +################### +#### DeepSpeed #### +################### +#DEEPSPEED - Reload the model when DeepSpeed checkbox is enabled/disabled +def send_deepspeed_request(deepspeed_param): + try: + params["model_loaded"] = False + url = f"{base_url}/api/deepspeed?new_deepspeed_value={deepspeed_param}" + headers = {"Content-Type": "application/json"} + response = requests.post(url, headers=headers) + response.raise_for_status() # Raises an HTTPError for bad responses + json_response = response.json() + # Check if the deepspeed request was successful + if json_response.get("status") == "deepspeed-success": + # Update any relevant variables or perform other actions on success + params["model_loaded"] = True + return json_response + except requests.exceptions.RequestException as e: + # Handle the HTTP request error + print(f"[CoquiTTS Server] \033[91mWarning\033[0m Error during request to webserver process: {e}") + return {"status": "error", "message": str(e)} + + +# DEEPSPEED - Display DeepSpeed Checkbox Yes or No +deepspeed_condition = params["tts_method_xtts_local"] == "True" and deepspeed_installed + +######################## +#### TTS GENERATION #### +######################## +#PREVIEW VOICE - Generate Random Sentence if Voice Preview box is empty +def random_sentence(): + with open(Path("extensions/coqui_tts/harvard_sentences.txt")) as f: + return random.choice(list(f)) + +#PREVIEW VOICE- Generate TTS Function +def voice_preview(string): + if not params['activate']: + return string + # Clean the string, capture model not loaded, and move model to cuda if needed + cleaned_string = before_audio_generation(string, params) + if cleaned_string is None: + return + string = cleaned_string + # Setup the output file + output_file = Path(params["output_folder_wav"]) / "voice_preview.wav" + # Generate the audio + language_code = languages.get(params["language"]) + # Convert the WindowsPath object to a string before using it in JSON payload + output_file_str = output_file.as_posix() + # Lock before making the generate request + with process_lock: + generate_response = send_generate_request(string, params["voice"], language_code, output_file_str) + # Check if lock is already acquired + if process_lock.locked(): + print("[CoquiTTS Model] \033[91mWarning\033[0m Audio generation is already in progress. Please wait.") + return + if generate_response.get("status") == "generate-success": + # Handle Gradio and playback + autoplay = 'autoplay' if params['autoplay'] else '' + return f'' + else: + # Handle the case where audio generation was not successful + return f"Audio generation failed. Status: {generate_response.get('status')}" + +#STANDARD VOICE - Generate TTS Function +def output_modifier(string, state): + if not params['activate']: + return string + original_string = string + cleaned_string = before_audio_generation(string, params) + if cleaned_string is None: + return + string = cleaned_string + # Setup the output file + output_file = Path(f'{params["output_folder_wav"]}/{state["character_menu"]}_{int(time.time())}.wav') + # Generate the audio and handle the response + language_code = languages.get(params["language"]) + # Convert the WindowsPath object to a string before using it in JSON payload + output_file_str = output_file.as_posix() + + # Lock before making the generate request + with process_lock: + generate_response = send_generate_request(string, params["voice"], language_code, output_file_str) + + # Check if lock is already acquired + if process_lock.locked(): + print("[CoquiTTS Model] \033[91mWarning\033[0m Audio generation is already in progress. Please wait.") + return + + if generate_response.get("status") == "generate-success": + audio_path = generate_response.get("data", {}).get("audio_path") + if audio_path: + # Handle Gradio and playback + autoplay = 'autoplay' if params['autoplay'] else '' + string = f'' + + if params['show_text']: + string += f'\n\n{original_string}' + shared.processing_message = "*Is typing...*" + + return string + else: + print("No audio path in the response.") + else: + print("[CoquiTTS Server] \033[91mWarning\033[0m Audio generation failed. Status:", generate_response.get("message")) + +def send_generate_request(text, voice, language, output_file): + url = f"{base_url}/api/generate" + payload = { + "text": text, + "voice": voice, + "language": language, + "output_file": output_file + } + headers = {"Content-Type": "application/json"} + response = requests.post(url, json=payload, headers=headers) + return response.json() + +############################################################# +#### TTS STRING CLEANING & PROCESSING PRE SENDING TO TTS #### +############################################################# +def preprocess(raw_input): + raw_input = html.unescape(raw_input) + # raw_input = raw_input.strip("\"") + return raw_input + +def new_split_into_sentences(self, text): + sentences = self.seg.segment(text) + if params['remove_trailing_dots']: + sentences_without_dots = [] + for sentence in sentences: + if sentence.endswith('.') and not sentence.endswith('...'): + sentence = sentence[:-1] + + sentences_without_dots.append(sentence) + + return sentences_without_dots + else: + return sentences + +Synthesizer.split_into_sentences = new_split_into_sentences + +#TTS STRING CLEANING - Clean String before TTS generation (Called from voice_preview and output_modifer) +def before_audio_generation(string, params): + #Check Model is loaded into cuda or cpu and error if not + if not params["model_loaded"]: + print("[CoquiTTS Model] \033[91mWarning\033[0m Model is still loading, please wait before trying to generate TTS") + return + string = html.unescape(string) or random_sentence() + # Replace double quotes with single, asterisks, carriage returns, and line feeds + string = string.replace('"', "'").replace(".'", "'.").replace('*', '').replace('\r', '').replace('\n', '') + if string == '': + return '*Empty string*' + return string + +################################ +#### SUBPORCESS TERMINATION #### +################################ +#Register the termination code to be executed at exit +atexit.register(lambda: process.terminate() if process.poll() is None else None) + +###################### +#### GRADIO STUFF #### +###################### +def state_modifier(state): + if not params['activate']: + return state + + state['stream'] = False + return state + +def input_modifier(string, state): + if not params['activate']: + return string + + shared.processing_message = "*Is recording a voice message...*" + return string + +def custom_css(): + path_to_css = Path(f"{this_dir}/style.css") + return open(path_to_css, 'r').read() + +def ui(): + with gr.Accordion("Coqui TTS (XTTSv2)"): + with gr.Row(): + activate = gr.Checkbox(value=params['activate'], label='Activate TTS') + autoplay = gr.Checkbox(value=params['autoplay'], label='Play TTS automatically') + + with gr.Row(): + show_text = gr.Checkbox(value=params['show_text'], label='Show message text under audio player') + remove_trailing_dots = gr.Checkbox(value=params['remove_trailing_dots'], label='Remove trailing "." from text segments before generation') + + with gr.Row(): + low_vram = gr.Checkbox(value=params['low_vram'], label='Low VRAM mode (Read NOTE)') + deepspeed_checkbox = gr.Checkbox(value=params['deepspeed_activate'], label='Activate DeepSpeed (Read NOTE)', visible=deepspeed_installed) + + with gr.Row(): + tts_radio_buttons = gr.Radio( + choices=["API TTS", "API Local", "XTTSv2 Local"], + label="Select TTS Generation Method (Read NOTE)", + value=gr_modelchoice # Set the default value + ) + explanation_text = gr.HTML(f"
NOTE: Switching Model Type, Low VRAM & DeepSpeed takes 15 seconds. Each TTS generation method has a slightly different sound. DeepSpeed checkbox is only visible if DeepSpeed is present. Readme & Settings: http://{params['ip_address']}:{params['port_number']}") + + with gr.Row(): + with gr.Row(): + voice = gr.Dropdown(get_available_voices(), label="Voice wav", value=params["voice"]) + create_refresh_button(voice, lambda: None, lambda: {'choices': get_available_voices(), 'value': params["voice"]}, 'refresh-button') + + language = gr.Dropdown(languages.keys(), label="Language", value=params["language"]) + + with gr.Row(): + preview_text = gr.Text(show_label=False, placeholder="Preview text", elem_id="silero_preview_text") + preview_play = gr.Button("Preview") + preview_audio = gr.HTML(visible=False) + + with gr.Row(): + convert = gr.Button('Permanently replace audios with the message texts') + convert_cancel = gr.Button('Cancel', visible=False) + convert_confirm = gr.Button('Confirm (cannot be undone)', variant="stop", visible=False) + + # Convert history with confirmation + convert_arr = [convert_confirm, convert, convert_cancel] + convert.click(lambda: [gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)], None, convert_arr) + convert_confirm.click( + lambda: [gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)], None, convert_arr).then( + remove_tts_from_history, gradio('history'), gradio('history')).then( + chat.save_history, gradio('history', 'unique_id', 'character_menu', 'mode'), None).then( + chat.redraw_html, gradio(ui_chat.reload_arr), gradio('display')) + + convert_cancel.click(lambda: [gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)], None, convert_arr) + + # Toggle message text in history + show_text.change( + lambda x: params.update({"show_text": x}), show_text, None).then( + toggle_text_in_history, gradio('history'), gradio('history')).then( + chat.save_history, gradio('history', 'unique_id', 'character_menu', 'mode'), None).then( + chat.redraw_html, gradio(ui_chat.reload_arr), gradio('display')) + + # Event functions to update the parameters in the backend + activate.change(lambda x: params.update({"activate": x}), activate, None) + autoplay.change(lambda x: params.update({"autoplay": x}), autoplay, None) + low_vram.change(lambda x: params.update({"low_vram": x}), low_vram, None) + low_vram.change(lambda x: send_lowvram_request(x), low_vram, None) + tts_radio_buttons.change(send_reload_request, tts_radio_buttons, None) + deepspeed_checkbox.change(send_deepspeed_request, deepspeed_checkbox, None) + remove_trailing_dots.change(lambda x: params.update({"remove_trailing_dots": x}), remove_trailing_dots, None) + voice.change(lambda x: params.update({"voice": x}), voice, None) + language.change(lambda x: params.update({"language": x}), language, None) + + # Play preview + preview_text.submit(voice_preview, preview_text, preview_audio) + preview_play.click(voice_preview, preview_text, preview_audio) diff --git a/style.css b/style.css new file mode 100644 index 0000000..2330a74 --- /dev/null +++ b/style.css @@ -0,0 +1,8 @@ +.SDAP .hires_opts input[type="number"] { + width: 6em !important; +} + +/* silero_tts preview */ +.form:has(> #silero_preview_text) { + min-width: 75% +} diff --git a/templates/generate_form.html b/templates/generate_form.html new file mode 100644 index 0000000..17bf741 --- /dev/null +++ b/templates/generate_form.html @@ -0,0 +1,205 @@ + + + +
+ + +WARNING: Changing RED items or setting DeepSpeed to True on a system without DeepSpeed installed, may cause errors.
+ + + + diff --git a/tts_server.py b/tts_server.py new file mode 100644 index 0000000..54e4072 --- /dev/null +++ b/tts_server.py @@ -0,0 +1,861 @@ +import json +import random +import time +import os +from pathlib import Path +import torch +import torchaudio +from TTS.tts.configs.xtts_config import XttsConfig +from TTS.tts.models.xtts import Xtts + +########################## +#### Webserver Imports#### +########################## +from fastapi import FastAPI, Form, Request, HTTPException, BackgroundTasks, Response, Depends +from fastapi.responses import JSONResponse, HTMLResponse, RedirectResponse +from fastapi.templating import Jinja2Templates +from contextlib import asynccontextmanager + +######################## +#### STARTUP CHECKS #### +######################## +try: + from TTS.api import TTS + from TTS.utils.synthesizer import Synthesizer +except ModuleNotFoundError: + logger.error( + "[CoquiTTS Startup] \033[91mWarning\033[0m Could not find the TTS module. Make sure to install the requirements for the coqui_tts extension." + "[CoquiTTS Startup] \033[91mWarning\033[0m Linux / Mac:\npip install -r extensions/coqui_tts/requirements.txt\n" + "[CoquiTTS Startup] \033[91mWarning\033[0m Windows:\npip install -r extensions\\coqui_tts\\requirements.txt\n" + "[CoquiTTS Startup] \033[91mWarning\033[0m If you used the one-click installer, paste the command above in the terminal window launched after running the \"cmd_\" script. On Windows, that's \"cmd_windows.bat\"." + ) + raise + +#DEEPSPEED Import - Check for DeepSpeed and import it if it exists +try: + import deepspeed + deepspeed_installed = True + print("[CoquiTTS Startup] DeepSpeed \033[93mDetected\033[0m") + print("[CoquiTTS Startup] Activate DeepSpeed in Coqui settings") +except ImportError: + deepspeed_installed = False + print("[CoquiTTS Startup] DeepSpeed \033[93mNot Detected\033[0m. See https://github.com/microsoft/DeepSpeed") + +@asynccontextmanager +async def startup_shutdown(no_actual_value_it_demanded_something_be_here): + await setup() + yield + # Shutdown logic + +########################### +#### STARTUP VARIABLES #### +########################### +#STARTUP VARIABLE - Set "device" to cuda if exists, otherwise cpu +device = "cuda" if torch.cuda.is_available() else "cpu" +#STARTUP VARIABLE - Create "this_dir" variable as the current script directory +this_dir = Path(__file__).parent.resolve() +#STARTUP VARIABLE - Import languges file for Gradio to be able to display them in the interface +with open(this_dir / 'languages.json', encoding='utf8') as f: + languages = json.load(f) +# Create FastAPI app with lifespan +app = FastAPI(lifespan=startup_shutdown) + +###################################### +#### LOAD PARAMS FROM CONFIG.JSON #### +###################################### +def load_config(file_path): + with open(file_path, 'r') as config_file: + config = json.load(config_file) + return config + +config_file_path = (this_dir / 'config.json') +params = load_config(config_file_path) + +############################################# +#### LOAD PARAMS FROM MODELDOWNLOAD.JSON #### +############################################ +#This is used only in the instance that someone has changed their model path +# Define the path to the JSON file +modeldownload_config_file_path = this_dir / 'modeldownload.json' + +#Check if the JSON file exists +if modeldownload_config_file_path.exists(): + with open(modeldownload_config_file_path, 'r') as modeldownload_config_file: + modeldownload_settings = json.load(modeldownload_config_file) + + #Extract settings from the loaded JSON + modeldownload_base_path = Path(modeldownload_settings.get("base_path", "")) + modeldownload_model_path = Path(modeldownload_settings.get("model_path", "")) +else: + #Default settings if the JSON file doesn't exist or is empty + print("[CoquiTTS Startup] \033[91mWarning\033[0m modeldownload.config is missing so please re-download it and save it in the coquii_tts main folder.") + +##################################### +#### MODEL LOADING AND UNLOADING #### +##################################### +#MODEL LOADERS Picker For API TTS, API Local, XTTSv2 Local +async def setup(): + global device + #Set a timer to calculate load times + generate_start_time = time.time() # Record the start time of loading the model + #Start loading the correct model as set by "tts_method_api_tts", "tts_method_api_local" or "tts_method_xtts_local" being True/False + if params["tts_method_api_tts"]: + print(f"[CoquiTTS Model] \033[94mAPI TTS Loading\033[0m {params['model_name']} \033[94minto\033[93m", device, "\033[0m") + model = await api_load_model() + elif params["tts_method_api_local"]: + print(f"[CoquiTTS Model] \033[94mAPI Local Loading\033[0m {modeldownload_model_path} \033[94minto\033[93m", device, "\033[0m") + model = await api_manual_load_model() + elif params["tts_method_xtts_local"]: + print(f"[CoquiTTS Model] \033[94mXTTSv2 Local Loading\033[0m {modeldownload_model_path} \033[94minto\033[93m", device, "\033[0m") + model = await xtts_manual_load_model() + #Create an end timer for calculating load times + generate_end_time = time.time() + #Calculate start time minus end time + generate_elapsed_time = generate_end_time - generate_start_time + #Print out the result of the load time + print(f"[CoquiTTS Model] \033[94mModel Loaded in \033[93m{generate_elapsed_time:.2f} seconds.\033[0m") + #Set "model_loaded" to true + params["model_loaded"] = True + #Set the output path for wav files + Path(f'{params["output_folder_wav"]}outputs/').mkdir(parents=True, exist_ok=True) + +#MODEL LOADER For "API TTS" +async def api_load_model(): + global model + model = TTS(params["model_name"]).to(device) + return model + +#MODEL LOADER For "API Local" +async def api_manual_load_model(): + global model + #check to see if a custom path has been set in modeldownload.json and use that path to load the model if so + if str(modeldownload_base_path) == "models": + model = TTS(model_path=this_dir / 'models' / modeldownload_model_path,config_path=this_dir / 'models' / modeldownload_model_path / 'config.json').to(device) + else: + print("[CoquiTTS Model] \033[94mInfo\033[0m Loading your custom model set in \033[93mmodeldownload.json\033[0m:", modeldownload_base_path / modeldownload_model_path) + model = TTS(model_path=modeldownload_base_path / modeldownload_model_path,config_path=modeldownload_base_path / modeldownload_model_path / 'config.json').to(device) + return model + +#MODEL LOADER For "XTTSv2 Local" +async def xtts_manual_load_model(): + global model + config = XttsConfig() + #check to see if a custom path has been set in modeldownload.json and use that path to load the model if so + if str(modeldownload_base_path) == "models": + config_path = this_dir / 'models' / modeldownload_model_path / 'config.json' + checkpoint_dir = this_dir / 'models' / modeldownload_model_path + else: + print("[CoquiTTS Model] \033[94mInfo\033[0m Loading your custom model set in \033[93mmodeldownload.json\033[0m:", modeldownload_base_path / modeldownload_model_path) + config_path = modeldownload_base_path / modeldownload_model_path / 'config.json' + checkpoint_dir = modeldownload_base_path / modeldownload_model_path + config.load_json(str(config_path)) + model = Xtts.init_from_config(config) + model.load_checkpoint(config, checkpoint_dir=str(checkpoint_dir), use_deepspeed=params['deepspeed_activate']) + model.cuda() + model.to(device) + return model + +#MODEL UNLOADER +async def unload_model(model): + print("[CoquiTTS Model] \033[94mUnloading model \033[0m") + del model + torch.cuda.empty_cache() + params["model_loaded"] = False + return None + +#MODEL - Swap model based on Gradio selection API TTS, API Local, XTTSv2 Local +async def handle_tts_method_change(tts_method): + global model + #Update the params dictionary based on the selected radio button + print("[CoquiTTS Model] \033[94mChanging model \033[92m(Please wait 15 seconds)\033[0m") + #Set other parameters to False + if tts_method == "API TTS": + params["tts_method_api_local"] = False + params["tts_method_xtts_local"] = False + params["tts_method_api_tts"] = True + params["deepspeed_activate"] = False + elif tts_method == "API Local": + params["tts_method_api_tts"] = False + params["tts_method_xtts_local"] = False + params["tts_method_api_local"] = True + params["deepspeed_activate"] = False + elif tts_method == "XTTSv2 Local": + params["tts_method_api_tts"] = False + params["tts_method_api_local"] = False + params["tts_method_xtts_local"] = True + + #Unload the current model + model = await unload_model(model) + + #Load the correct model based on the updated params + await setup() + +#MODEL WEBSERVER- API Swap Between Models +@app.route("/api/reload", methods=["POST"]) +async def reload(request: Request): + tts_method = request.query_params.get("tts_method") + if tts_method not in ["API TTS", "API Local", "XTTSv2 Local"]: + return {"status": "error", "message": "Invalid TTS method specified"} + await handle_tts_method_change(tts_method) + return Response( + content=json.dumps({"status": "model-success"}), + media_type="application/json" + ) + +################## +#### LOW VRAM #### +################## +#LOW VRAM - MODEL MOVER VRAM(cuda)<>System RAM(cpu) for Low VRAM setting +async def switch_device(): + global model, device + if device == "cuda": + device = "cpu" + model.to(device) + torch.cuda.empty_cache() + else: + device == "cpu" + device = "cuda" + model.to(device) + +@app.post("/api/lowvramsetting") +async def set_low_vram(request: Request, new_low_vram_value: bool): + global device + try: + if new_low_vram_value is None: + raise ValueError("Missing 'low_vram' parameter") + if params["low_vram"] == new_low_vram_value: + return Response( + content=json.dumps({"status": "success", "message": f"[CoquiTTS Model] LowVRAM is already {'enabled' if new_low_vram_value else 'disabled'}."})) + params["low_vram"] = new_low_vram_value + if params["low_vram"]: + await unload_model(model) + device = "cpu" + print("[CoquiTTS Model] \033[94mChanging model \033[92m(Please wait 15 seconds)\033[0m") + print("[CoquiTTS Model] \033[94mLowVRAM Enabled.\033[0m Model will move between \033[93mVRAM(cuda) <> System RAM(cpu)\033[0m") + await setup() + else: + await unload_model(model) + device = "cuda" + print("[CoquiTTS Model] \033[94mChanging model \033[92m(Please wait 15 seconds)\033[0m") + print("[CoquiTTS Model] \033[94mLowVRAM Disabled.\033[0m Model will stay in \033[93mVRAM(cuda)\033[0m") + await setup() + return Response(content=json.dumps({"status": "lowvram-success"})) + except Exception as e: + return Response(content=json.dumps({"status": "error", "message": str(e)})) + +################### +#### DeepSpeed #### +################### +#DEEPSPEED - Reload the model when DeepSpeed checkbox is enabled/disabled +async def handle_deepspeed_change(value): + global model + if value: + # DeepSpeed enabled + print("[CoquiTTS Model] \033[93mDeepSpeed Activating\033[0m") + print("[CoquiTTS Model] \033[94mChanging model \033[92m(DeepSpeed can take 30 seconds to activate)\033[0m") + print("[CoquiTTS Model] \033[91mInformation\033[0m If you have not set CUDA_HOME path, DeepSpeed may fail to load/activate") + print("[CoquiTTS Model] \033[91mInformation\033[0m DeepSpeed needs to find nvcc from the CUDA Toolkit. Please check your CUDA_HOME path is") + print("[CoquiTTS Model] \033[91mInformation\033[0m pointing to the correct location and use 'set CUDA_HOME=putyoutpathhere' (Windows) or") + print("[CoquiTTS Model] \033[91mInformation\033[0m 'export CUDA_HOME=putyoutpathhere' (Linux) within your Python Environment") + model = await unload_model(model) + params["tts_method_api_tts"] = False + params["tts_method_api_local"] = False + params["tts_method_xtts_local"] = True + params["deepspeed_activate"] = True + await setup() + else: + # DeepSpeed disabled + print("[CoquiTTS Model] \033[93mDeepSpeed De-Activating\033[0m") + print("[CoquiTTS Model] \033[94mChanging model \033[92m(Please wait 15 seconds)\033[0m") + params["deepspeed_activate"] = False + model = await unload_model(model) + await setup() + + return value # Return new checkbox value + +#DEEPSPEED WEBSERVER- API Enable/Disable DeepSpeed +@app.post("/api/deepspeed") +async def deepspeed(request: Request, new_deepspeed_value: bool): + try: + if new_deepspeed_value is None: + raise ValueError("Missing 'deepspeed' parameter") + if params["deepspeed_activate"] == new_deepspeed_value: + return Response( + content=json.dumps({"status": "success", "message": f"DeepSpeed is already {'enabled' if new_deepspeed_value else 'disabled'}."})) + params["deepspeed_activate"] = new_deepspeed_value + await handle_deepspeed_change(params["deepspeed_activate"]) + return Response(content=json.dumps({"status": "deepspeed-success"})) + except Exception as e: + return Response(content=json.dumps({"status": "error", "message": str(e)})) + +######################## +#### TTS GENERATION #### +######################## +#TTS VOICE GENERATION METHODS (called from voice_preview and output_modifer) +async def generate_audio(text, voice, language, output_file): + global model + if params["low_vram"] and device == "cpu": + await switch_device() + generate_start_time = time.time() # Record the start time of generating TTS + #XTTSv2 LOCAL Method + if params["tts_method_xtts_local"]: + print("[CoquiTTS TTSGen] {}".format(text)) + gpt_cond_latent, speaker_embedding = model.get_conditioning_latents(audio_path=[f"{this_dir}/voices/{voice}"]) + out = model.inference( + text, + language, + gpt_cond_latent=gpt_cond_latent, + speaker_embedding=speaker_embedding, + temperature=0.7, + enable_text_splitting=True + ) + torchaudio.save(output_file, torch.tensor(out["wav"]).unsqueeze(0), 24000) + #API TTS and API LOCAL Methods + elif params["tts_method_api_tts"] or params["tts_method_api_local"]: + #Set the correct output path (different from the if statement) + print("[CoquiTTS TTSGen] Using API TTS/Local Method") + model.tts_to_file( + text=text, + file_path=output_file, + speaker_wav=[f"{this_dir}/voices/{voice}"], + language=language, + ) + #Print Generation time and settings + generate_end_time = time.time() # Record the end time to generate TTS + generate_elapsed_time = generate_end_time - generate_start_time + print(f"[CoquiTTS TTSGen] \033[93m{generate_elapsed_time:.2f} seconds. \033[94mLowVRAM: \033[33m{params['low_vram']} \033[94mDeepSpeed: \033[33m{params['deepspeed_activate']}\033[0m") + #Move model back to cpu system ram if needed. + if params["low_vram"] and device == "cuda": + await switch_device() + return + +#TTS VOICE GENERATION METHODS - generate TTS API +@app.route("/api/generate", methods=["POST"]) +async def generate(request: Request): + try: + # Get parameters from JSON body + data = await request.json() + text = data["text"] + voice = data["voice"] + language = data["language"] + output_file = data["output_file"] + # Generation logic + await generate_audio(text, voice, language, output_file) + return JSONResponse(content={"status": "generate-success", "data": {"audio_path": output_file}}) + except Exception as e: + return JSONResponse(content={"status": "error", "message": str(e)}) + +############################# +#### JSON CONFIG UPDATER #### +############################# + +#Create an instance of Jinja2Templates for rendering HTML templates +templates = Jinja2Templates(directory=this_dir / "templates") + +#Create a dependency to get the current JSON data +def get_json_data(): + with open(this_dir / 'config.json', "r") as json_file: + data = json.load(json_file) + return data + +#Define an endpoint function +@app.get("/settings") +async def get_settings(request: Request): + # Render the template with the current JSON data + return templates.TemplateResponse("generate_form.html", {"request": request, "data": get_json_data(), "modeldownload_model_path": modeldownload_model_path}) + +@app.post("/update-settings") +async def update_settings( + request: Request, + activate: bool = Form(...), + autoplay: bool = Form(...), + deepspeed_activate: bool = Form(...), + delete_output_wavs: str = Form(...), + ip_address: str = Form(...), + language: str = Form(...), + low_vram: bool = Form(...), + model_loaded: bool = Form(...), + model_name: str = Form(...), + output_folder_wav: str = Form(...), + port_number: str = Form(...), + remove_trailing_dots: bool = Form(...), + show_text: bool = Form(...), + tts_method: str = Form(...), + voice: str = Form(...), + data: dict = Depends(get_json_data), +): + # Update the settings based on the form values + data["activate"] = activate + data["autoplay"] = autoplay + data["deepspeed_activate"] = deepspeed_activate + data["delete_output_wavs"] = delete_output_wavs + data["ip_address"] = ip_address + data["language"] = language + data["low_vram"] = low_vram + data["model_loaded"] = model_loaded + data["model_name"] = model_name + data["output_folder_wav"] = output_folder_wav + data["port_number"] = port_number + data["remove_trailing_dots"] = remove_trailing_dots + data["show_text"] = show_text + data["tts_method_api_local"] = tts_method == "api_local" + data["tts_method_api_tts"] = tts_method == "api_tts" + data["tts_method_xtts_local"] = tts_method == "xtts_local" + data["voice"] = voice + + #Save the updated settings back to the JSON file + with open(this_dir / 'config.json', "w") as json_file: + json.dump(data, json_file) + + #Redirect to the settings page to display the updated settings + return RedirectResponse(url="/settings", status_code=303) + +############################################################# +#### DOCUMENTATION - README ETC - PRESENTED AS A WEBPAGE #### +############################################################# + +simple_webpage = """ + + + + + + +If you are looking for your Text-generation-WebUI webpage, try visiting http://127.0.0.1:7860.
+Text-generation-WebUI documentation and wiki https://github.com/oobabooga/text-generation-webui/wiki.
+ + + +To generate TTS, you can use the provided interface or interact with the server using CURL commands. Below are some details and examples:
+ +http://127.0.0.1:7851http://127.0.0.1:7851/readyVoice samples are stored in /extensions/coqui_tts/voices/ and should be named using the following format name.wav
+Voice samples are stored in /extensions/coqui_tts/outputs/
+You can configure automatic maintenence deletion of old wav files by setting "Del WAV's older than" in the settings above. When "Disabled" your output wav files will be left untouched. When set to a setting "1 Day" or greater, your output wav files older than that time period will be automatically deleted on startup.
+This extension will download the 2.0.2 model to /extensions/coqui_tts/models/
+This TTS engine will also download the latest available model and store it wherever it normally stores it for your OS (Windows/Linux/Mac).
+To create a new voice sample you need to make a wav file that is 22050Hz, Mono, 16 bit and between 6 to 12 seconds long, though 7 to 9 seconds is usually good.
+You want to find a nice clear selection of audio, so lets say you wanted to clone your favourite celebrity. You may go looking for an interview where they are talking. Pay close attention to the audio you are listening to and trying to sample, are there noises in the backgroud, hiss on the soundtrack, a low humm, some quiet music playing or something? The better quality the audio the better the result. Dont forget, the AI that processes the sounds can hear everything, all those liitle noises, and it will use them in the voice its trying to recreate.
+Try make your clip one of nice flowing speech, like the included example files. No big pauses, gaps or other sounds. Preferably one that the person you are trying to copy will show a little vocal range and emotion in their voice. Also, try to avoid a clip starting or ending with breathy sounds (breathing in/out etc).
+So youve downloaded your favoutie celebrity interview off Youtube or wherever. From here you need to chop it down to 6 to 12 seconds in length and resample it. If you need to clean it up, do audio processing, volume level changes etc, do it before the steps I am about to describe.
+Using the latest version of Audacity, select your clip and Tracks > Resample to 22050Hz, then Tracks > Mix > Stereo to Mono. and then File > Export Audio, saving it as a WAV of 22050Hz.
+Save your generated wav file in /extensions/coqui_tts/voices/
+Note: Using AI generated audio clips may introduce unwanted sounds as its already a copy/simulation of a voice.
+The reasons can be that you:
+The Low VRAM option is a crucial feature designed to enhance performance under constrained Video Random Access Memory (VRAM) conditions, as the TTS models require 2GB-3GB of VRAM to run effectively. This feature strategically manages the relocation of the Text-to-Speech (TTS) model between your system's Random Access Memory (RAM) and VRAM, moving it between the two on the fly.
+ +The Low VRAM option intelligently orchestrates the relocation of the entire TTS model. When the TTS engine requires VRAM for processing, the entire model seamlessly moves into VRAM, causing your LLM to unload/displace some layers, ensuring optimal performance of the TTS engine.
+The TTS model is fully loaded into VRAM, facilitating uninterrupted and efficient TTS generation, creating contiguous space for the TTS model and significantly accelerating TTS processing, especially for long paragraphs. Post-TTS processing, the model promptly moves back to RAM, freeing up VRAM space for your Language Model (LLM) to load back in the missing layers. This adds about 1-2 seconds to both text generation by the LLM and the TTS engine.
+By transferring the entire model between RAM and VRAM, the Low VRAM option avoids fragmentation, ensuring the TTS model remains cohesive and accessible.
+This creates a TTS generation performance Boost for Low VRAM Users and is particularly beneficial for users with less than 2GB of free VRAM after loading their LLM, delivering a substantial 5-10x improvement in TTS generation speed.
+ + +DeepSpeed, developed by Microsoft, is like a speed boost for Text-to-Speech (TTS) tasks. It's all about making TTS happen faster and more efficiently.
+ +Note: DeepSpeed only works with the XTTSv2 Local model.
+Note: Requires Nvidia Cuda Toolkit installation and correct CUDA_HOME path configuration.
+ +In CoquiTTS, the DeepSpeed checkbox will only be available if DeepSpeed is detected on your system. Check the checkbox, wait 10 to 30 seconds and off you go!
+ + +Note: DeepSpeed WILL throw up a load of errors if you have not installed it fully, correctly, or installed the Nvidia Cuda Toolkit and correctly set the CUDA_HOME environment variable or if load text-generation-webui via its start-up scripts.
+ +sudo apt install libaio-devcd text-generation-webui./start_linux.sh./start_linux.shexport CUDA_HOME=/usr/local/cuda or export CUDA_HOME=/etc/alternatives/cuda. On some systems only one of those two commands may be the correct command, so you may need to try one, see if it works, if not try the other. IF you do not set it, expect a big messy output to the log when you try to activate DeepSpeed.pip install deepspeedNote: You can run ds_report when you have installed DeepSpeed on your system to see if it is working correctly
python server.py ensuring to activate your extensions.Currently DeepSpeed 8.3 is the latest build that works on Windows and it has to run inside a Python 3.9.18 environment. As such, either you need to have your own, already set up Python 3.9.18 environment and have installed the correct text-generation-webui requirements file into it. Or you can create a new Python environment. DeepSpeed version 9.x, 10.x, 11.x, and 12.x will all fail to compile (on Windows) for a multitude of reasons. As such, DeepSpeed v8.3 is the most recent build for Windows.
+ +Option A is to fully go through the process of compiling DeepSpeed yourself. This takes a longer time to perform, but you can be sure it's set up for your system correctly.
+ +Option B is to download someone else's precompiled wheels. If you can find someone's precompiled wheel file, you only need to follow Option B.
+ +CUDA_HOME=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8CUDA_HOME=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1set command at the command prompt when inside your python environment e.g. set CUDA_HOME=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1'. You can then just type set again, and it will show you the list of all currently set environment variables so that you can confirm you have them set correctly.
+ conda create -n pythonenv python=3.9.18
+ activate pythonenv
+ activate pythonenv (activate your python environment)conda install pytorch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 pytorch-cuda=11.8 -c pytorch -c nvidiaactivate pythonenv (activate your python environment)conda install pytorch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 pytorch-cuda=12.1 -c pytorch -c nvidia
+ set to list and check the Windows environment variables. Refer to step 4 if not.
+ cd c:\deepspeed (wherever you extracted it to)
+ set DS_BUILD_AIO=0
+ set DS_BUILD_SPARSE_ATTN=0
+ set DS_BUILD_EVOFORMER_ATTN=0
+ build_win.bat (This will start building your wheel file and may take a while)
+ ds_report when you have installed DeepSpeed on your system to see if it is working correctly
+ cd text-generation-webuipip install -r requirements.txt or whichever requirements file you want to use for your system, within the text-generation-webui folder.python server.py ensuring to activate your extensions.
+ Ensures a minimum TTS version (0.21.3) is installed and provides an error/instructions if not.
+Performs a basic environment check to ensure everything should work e.g. is the model already downloaded, are the configuration files set correctly etc.
+Downloads the Xtts model (version 2.0.2) to improve generation speech quality as the 2.0.3 model sounded terrible. The API TTS version uses the latest model (2.0.3 at the time of writing) so you have the best of both worlds.
+ + +It's worth noting that all models and methods can and do sound different from one another. Many people complained about the quality of audio produced by the 2.0.3 model, so this extension will download the 2.0.2 model to your models folder and give you the choice to use 2.0.2 (API Local and XTTSv2 Local) or use the most current model 2.0.3 (API TTS). As/When a new model is released by Coqui it will be downloaded by the TTS service on startup and stored wherever the TTS service keeps new models on your operating system of choice.
+Its possible to set a custom model for the API Local and XTTSv2 Local methods, or ideed point it at the same model that API TTS uses (wherever it is stored on your OS of choice). Many people did not like the sound quality of the Coqui 2.0.3 model, and as such the Coqui_tts extension downloads the 2.0.2 model seperately to the 2.0.3 model that TTS service downloads and manages. Typically the 2.0.2 model is stored in your /extensions/coqui_tts/models folder and it is always downloaded on first start-up of the Coqui_tts extension. However, you may either want to use a custom model version of your choosing, or point it to a different path on your system, or even point it so that API Local and XTTSv2 both use the same model that API TTS is using.
+If you do choose to change the location there are a couple of things to note.
+- The folder you place the model in, cannot be called "models". This name is reserved solely for the system to identify you are or are not using a custom model.
+- On each startup, the Coqui_tts extension will check the custom location and if it does not exist, it will create it and download the files it needs. It will also re download any missing files in that location that are needed for the model to function.
+- There will be extra output at the console to inform you that you are using a custom model and each time you load up the Coqui_tts extension or switch between models.
+To change the model path, there are at minimum 2x settings you need to alter in the modeldownload.json file, base_path and model_path. These two settings are further detailed in the section below called Explanation of the modeldownload.json file
+You would edit the settings in the modeldownload.json file as follows (make a backup of your current file in case):
+Windows example: c:\mystuff\mydownloads\myTTSmodel\{files in here}
+ +Note: On Windows systems, you have to specify a double backslash \\ for each folder level in the path (as above).
+Linux example: /home/myaccount/myTTSmodel/{files in here}
+ +Once you restart the Coqui_tts extension, it will check this path for the files and output any details at the console.
+When you are happy it's' working correctly, you are welcome to go delete the models folder stored at /extensions/coqui_tts/models.
+If you wish to change the files that the modeldownloader is pulling at startup, you can futher edit the modeldownload.json and change the http addresses within this files files_to_download section e.g.
+ "files_to_download": {
+ "LICENSE.txt": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/LICENSE.txt?download=true",
+ "README.md": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/README.md?download=true",
+ "config.json": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/config.json?download=true",
+ "model.pth": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/model.pth?download=true",
+ "vocab.json": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/vocab.json?download=true"
+ }
Explanation of the config.json file:
+ +"activate:" true, Used within the code, do not change."autoplay:" true, Controls whether the TTS audio plays automatically within Text-generation-webUI."deepspeed_activate:" false, Controls whether the DeepSpeed option is activated or disabled in the Gradio interface."delete_output_wavs:" ""Disabled"", If set this will delete your old output wav files, older than the date set, when the system starts up."ip_address:" "127.0.0.1", Specifies the default IP address for the web server."language:" "English", Specifies the default language to use for TTS."low_vram:" false, Controls whether the Low VRAM option is enabled or disabled."model_loaded:" true, Used within the code, do not change."model_name:" "tts_models/multilingual/multi-dataset/xtts_v2", Specifies the model that the "API TTS" method will use for TTS generation."port_number:" "7851", Specifies the default port number for the web server."output_folder_wav:" "extensions/coqui_tts/outputs/", Sets the output folder to send files to on generating TTS."remove_trailing_dots:" false, Controls whether trailing dots are removed from text segments before generation."show_text:" true, Controls whether message text is shown under the audio player."tts_method_api_local:" false, Controls whether the "API Local" model/method is turned on or off."tts_method_api_tts:" false, Controls whether the "API TTS" model/method is turned on or off."tts_method_xtts_local:" true, Controls whether the "XTTSv2 Local" model/method is turned on or off."voice:" "female_01.wav" Specifies the default voice to use for TTS.Explanation of the modeldownload.json file:
+ +"base_path:" "models", Specifies the base directory for the TTS models. If this is changed from the word "models" then the new custom path will be used e.g. C:\\mymodels(Please note the use of a double backslash \\ between folders on Windows systems. Linux systems will use "/mymodels" style)
+"model_path:" "xttsv2_2.0.2", Specifies the directory path for the XTTSv2 model underneath the base_path.So if base_path is C:\\mymodels and model_path is xttsv2_2.0.2, then your path would become c:\\mymodels\\xttsv2_2.0.2
+"files_to_download:" Dictionary containing files to download with their respective URLs. "LICENSE.txt": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/LICENSE.txt?download=true", License file URL. "README.md": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/README.md?download=true", README file URL. "config.json": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/config.json?download=true", Config file URL. "model.pth": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/model.pth?download=true", Model file URL. "vocab.json": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/vocab.json?download=true", Vocabulary file URL.If you wish to set your own path
+ +Generating TTS - Linux
+curl -X POST -H "Content-Type: application/json" -d '{"text": "This is text to generate as TTS","voice": "female_01.wav", "language": "en", "output_file": "outputfile.wav"}' "http://127.0.0.1:7851/api/generate"
+ Generating TTS - Windows
+curl -X POST -H "Content-Type: application/json" -d="{\"text\": \"This is text to generate as TTS\",\"voice\": \"female_01.wav\", \"language\": \"en\", \"output_file\": \"outputfile.wav\"}" 'http://127.0.0.1:7851/api/generate'
+ Generating TTS - Notes
+Replace This is text to generate as TTS with whatever you want it to say. female_01.wav with the voice sample you want to use. output_file.wav with the file name you want it to create.
JSON return {"status":"generate-success","data":{"audio_path":"outputfile.wav"}}
Switch Model
+curl -X POST "http://127.0.0.1:7851/api/reload?tts_method=API%20Local"curl -X POST "http://127.0.0.1:7851/api/reload?tts_method=API%20TTS"curl -X POST "http://127.0.0.1:7851/api/reload?tts_method=XTTSv2%20Local"
+ Switch between the 3 models respectively.
+JSON return {"status": "model-success"}
Switch DeepSpeed on/off
+curl -X POST -H "Content-Type: application/json" "http://127.0.0.1:7851/api/deepspeed?new_deepspeed_value=True"
+ Replace True with False to disable DeepSpeed mode.
JSON return {"status": "deepspeed-success"}
Note: Enabling DeepSpeed on systems that dont have DeepSpeed installed, may cause errors.
+ +Switch Low VRAM on/off
+curl -X POST -H "Content-Type: application/json" "http://127.0.0.1:7851/api/lowvramsetting?new_low_vram_value=True"
+ Replace True with False to disable Low VRAM mode.
JSON return {"status": "lowvram-success"}
Command line outputs are more verbose to assist in understanding backend processes and debugging.
+Its possible during startup you can get a warning message such as [CoquiTTS Startup] Warning TTS Subprocess has NOT started up yet, Will keep trying for 60 seconds maximum This is normal behavior if the subprocess is taking a while to start, however, if there is an issue starting the subprocess, you may see multiples of this message and an it will time out after 60 seconds, resulting in the TTS engine not starting. Its likely that you are not in the correct python environment or one that has a TTS engine inside, if this happens, though the system will output a warning about that ahead of this message
+Typically the command line console will output any warning or error messages. If you need to reset your default configuation, the settings are all listed above in the configuration details.
+ + +