Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move crate docs to readme #3

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,42 @@

This crate handles parsing SSML (Speech Synthesis Markup Language). It's main
aim is to facilitate the development of TTS (Text-To-Speech) and applications
that utilise sythesised audio.
that utilise sythesised audio. Functionality for writing XML is limited and
could do with improvements for ergonomics.

Currently it contains a full implementation of the SSML 1.1 specification
including custom tags. Text within custom tags is assumed to be synthesisable
though it is possible to change this behaviour when extracting the text.

Below is a simple example:

```
use ssml_parser::parse_ssml;

let ssml = r#"<?xml version="1.0"?>
<speak version="1.1"
xmlns="http://www.w3.org/2001/10/synthesis"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/10/synthesis
http://www.w3.org/TR/speech-synthesis11/synthesis.xsd"
xml:lang="en-US">
<p>
<s>You have 4 new messages.</s>
<s>The first is from Stephanie Williams and arrived at <break/> 3:45pm.
</s>
<s>
The subject is <prosody rate="20%">ski trip</prosody>
</s>
</p>
</speak>"#;

let result = parse_ssml(ssml).unwrap();

// We can now see the text with tags removed:
println!("{}", result.get_text());

// And can loop over all the SSML tags and get their character indexes:
for tag in result.tags() {
println!("{:?}", tag);
}
```
39 changes: 1 addition & 38 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,4 @@
//! The main focus on this crate is parsing not writing SSML, although there is some basic writing
//! support to support Emotech applications. The main function people will want to use is
//! `parse_ssml` which returns an `Ssml` structure which breaks down the text into it's elements.
//!
//! Below is a simple example:
//!
//! ```
//! use ssml_parser::parse_ssml;
//!
//! let ssml = r#"<?xml version="1.0"?>
//! <speak version="1.1"
//! xmlns="http://www.w3.org/2001/10/synthesis"
//! xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
//! xsi:schemaLocation="http://www.w3.org/2001/10/synthesis
//! http://www.w3.org/TR/speech-synthesis11/synthesis.xsd"
//! xml:lang="en-US">
//! <p>
//! <s>You have 4 new messages.</s>
//! <s>The first is from Stephanie Williams and arrived at <break/> 3:45pm.
//! </s>
//! <s>
//! The subject is <prosody rate="20%">ski trip</prosody>
//! </s>
//! </p>
//! </speak>"#;
//!
//! let result = parse_ssml(ssml).unwrap();
//!
//! // We can now see the text with tags removed:
//!
//! println!("{}", result.get_text());
//!
//! // And can loop over all the SSML tags and get their character indexes:
//!
//! for tag in result.tags() {
//! println!("{:?}", tag);
//! }
//! ```
#![doc = include_str!("../README.md")]
use crate::{elements::SsmlElement, parser::Span};
use elements::ParsedElement;
use std::fmt;
Expand Down