The relationship between gas content and star formation rate in spiral galaxies. Comparing the local field with the Virgo cluster