<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Llais Synthetig Cymraeg / Welsh Synthetic Voice</title>
	<link rel="stylesheet" href="css/style.css">
	<!--[if IE]>
		<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
        <style type="text/css">
        code {
            display: block;
            overflow:scroll;
            width:800px;
            border:1px solid #999;
            padding:0 20px;
            margin:20px 0 20px 40px;
        }
        #llais {
            width:400px;
            display:block;
            padding:10px;
            margin-left:40px;
        }
        button {
            margin-left:40px;
        }
        </style>
</head>

<body id="home">
    <h1>Demo Llais Synthetig Cymraeg / Welsh Synthetic Language Demo</h1>
    
    <h3>HTML5 &lt;audio&gt;</h3>
    <blockquote><em>"Mae hyn yn llais synthetig Cymraeg sydd wedi ei greu gan Prifysgol Bangor"</em></blockquote>

<audio controls>
  <source src="https://api.techiaith.org/festival/v1?api_key=ALLWEDD_API&text=Mae%20hyn%20yn%20llais%20synthetig%20Cymraeg%20sydd%20wedi%20ei%20greu%20gan%20Prifysgol%20Bangor" type="audio/ogg">
Your browser does not support the audio element.
</audio>

<h4>Cod /Code:</h4>
<code><xmp><audio controls>
<source src="https://api.techiaith.org/festival/v1?api_key=ALLWEDD_API&text=Mae%20hyn%20yn%20llais%20synthetig%20Cymraeg%20sydd%20wedi%20ei%20greu%20gan%20Prifysgol%20Bangor" type="audio/ogg">
Your browser does not support the audio element.
</audio></xmp></code>

<hr/>

<h3>Autoplay</h3>
<p>Mae'r sain yn cael ei chwarae'n syth / the audio is autoplayed</p>
<blockquote><em>"Dyma llais synthetig Cymraeg sy'n cael ei chwarae'n awtomatig"</em></blockquote>

<audio controls >
  <source src="https://api.techiaith.org/festival/v1?api_key=ALLWEDD_API&text=Dyma%llais%20synthetig%20Cymraeg%20sy'n%20cael%20ei%20chwarae'n%20awtomatig" type="audio/ogg">
Your browser does not support the audio element.
</audio>

<h4>Cod / Code</h4>

<code><xmp><audio controls autoplay>
  <source src="https://api.techiaith.org/festival/v1?api_key=ALLWEDD_API&text=Dyma%llais%20synthetig%20Cymraeg%20sy'n%20cael%20ei%20chwarae'n%20awtomatig" type="audio/ogg">
Your browser does not support the audio element.
</audio></xmp></code>

<hr/>

<h3>Cyflymu neu Arafu'r Llais / Speed up or slow down the voice</h3>
<p>Mae modd cyflymu neu arafu'r llais gyda'r paramedr 'stretch'. Mae rhif llai nag 1 yn cyflymu'r llais (e.e. 0.5 yn dyblu'r cyflymder) a rhif mwy nag 1 yn arafu'r llais (e.e. 2 yn haneru'r cyflymder).</p>
<p>It's possible to speed up or slow down the voice using the 'stretch' parameter. A number less than 1 speeds up the voice (e.g. 0.5 doubles the speed) and a number greater than 1 slows down the voice (e.g. 2 halves the speed)</p>

<blockquote><em>"Rydw i'n siarad Cymraeg yn gyflym iawn iawn!"</em></blockquote>

<audio controls>
  <source src="https://api.techiaith.org/festival/v1?api_key=ALLWEDD_API&text=Rydw%20i'n%20siarad%20Cymraeg%20yn%20gyflym%20iawn%iawn&stretch=0.6" type="audio/ogg">
Your browser does not support the audio element.
</audio>

<h4>Cod / Code:</h4>

<code><xmp><audio controls>
  <source src="https://api.techiaith.org/festival/v1?api_key=ALLWEDD_API&text=Rydw%20i'n%20siarad%20Cymraeg%20yn%20gyflym%20iawn%20iawn&stretch=0.6" type="audio/ogg">
Your browser does not support the audio element.
</audio></xmp></code>

<hr/>

<h3>Lais Cymraeg trwy Javascript / Welsh voice through Javascript</h3>

<textarea id='llais'>
Ysgrifennwch rhywbeth i'w llefaru
</textarea>

<script type='text/javascript'>
function llefaru() {
    var testun = document.getElementById('llais').value.trim();
    var audioElement = document.createElement('audio');
    var url = "https://api.techiaith.org/festival/v1?api_key=ALLWEDD_API&text=" + encodeURI(testun);
    audioElement.setAttribute('src', url);
    audioElement.play();
}
</script>
<p>
<button onclick="llefaru()">Chwarae / Play</button>
</p>

<p><strong>Cod / Code:</strong></p>

<code><xmp><textarea id='llais'>
Ysgrifennwch rhywbeth i'w llefaru
</textarea>

<script type='text/javascript'>
function llefaru() {
    var testun = document.getElementById('llais').value.trim();
    var audioElement = document.createElement('audio');
    var url = "https://api.techiaith.org/festival/v1?api_key=ALLWEDD_API&text=" + encodeURI(testun);
    audioElement.setAttribute('src', url);
    audioElement.play();
}
</script>
<p>
<button onclick="llefaru()">Chwarae / Play</button>
</p></xmp></code>

</body>
</html>